From 8b595e705155b11f08cda27e7fa61281896d3c48 Mon Sep 17 00:00:00 2001 From: Chandler J Date: Wed, 31 Jan 2024 19:17:56 -0700 Subject: improved random wallpaper picker --- src/user_interface.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/user_interface.py b/src/user_interface.py index 99eb524..f3d068a 100644 --- a/src/user_interface.py +++ b/src/user_interface.py @@ -38,8 +38,16 @@ def colorPickerUI(img_path: str) -> tuple: def pickRandomWallpaper() -> str: confirmed = False + history = [] + num_wallpapers = len(os.listdir(Paths['wallpapers'])) while not confirmed: + if len(history) == num_wallpapers: + print('[bold blue] Wallpapers exhausted. Resetting history...') + history.clear() wallpaper = Paths['wallpapers'] + random.choice(os.listdir(Paths['wallpapers'])) + if wallpaper in history: + continue + history.append(wallpaper) # TODO: Replace image preview with something native to python # (Currently borrowing viu module from Rust) os.system(f'viu {wallpaper}') -- cgit v1.2.3