diff options
| author | Chandler J <cjustice2000@gmail.com> | 2024-01-31 19:17:56 -0700 |
|---|---|---|
| committer | Chandler J <cjustice2000@gmail.com> | 2024-01-31 19:17:56 -0700 |
| commit | 8b595e705155b11f08cda27e7fa61281896d3c48 (patch) | |
| tree | a7dd7c2a984022cea800610a01837aa520a9ff9d /src/user_interface.py | |
| parent | 21e53dd011a20dd237abfbe093bbb465fda1c11d (diff) | |
improved random wallpaper picker
Diffstat (limited to 'src/user_interface.py')
| -rw-r--r-- | src/user_interface.py | 8 |
1 files changed, 8 insertions, 0 deletions
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}') |
