summaryrefslogtreecommitdiff
path: root/src/caelestia/utils
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-23 16:22:09 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-23 16:22:09 +1000
commit6cdfe72e8b14de7d1df61873b9c4c1d627b6bfc2 (patch)
tree9aec2748740162b4d2902506dcef926fd0f8ba11 /src/caelestia/utils
parent[CI] chore: update flake (diff)
downloadcaelestia-cli-6cdfe72e8b14de7d1df61873b9c4c1d627b6bfc2.tar.gz
caelestia-cli-6cdfe72e8b14de7d1df61873b9c4c1d627b6bfc2.tar.bz2
caelestia-cli-6cdfe72e8b14de7d1df61873b9c4c1d627b6bfc2.zip
wallpaper: random prevent duplicate
Diffstat (limited to 'src/caelestia/utils')
-rw-r--r--src/caelestia/utils/wallpaper.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/caelestia/utils/wallpaper.py b/src/caelestia/utils/wallpaper.py
index 6c6532c..9f75091 100644
--- a/src/caelestia/utils/wallpaper.py
+++ b/src/caelestia/utils/wallpaper.py
@@ -160,4 +160,18 @@ def set_wallpaper(wall: Path | str, no_smart: bool) -> None:
def set_random(args: Namespace) -> None:
- set_wallpaper(random.choice(get_wallpapers(args)), args.no_smart)
+ wallpapers = get_wallpapers(args)
+
+ if not wallpapers:
+ raise ValueError("No valid wallpapers found")
+
+ try:
+ last_wall = wallpaper_path_path.read_text()
+ wallpapers.remove(Path(last_wall))
+
+ if not wallpapers:
+ raise ValueError("Only valid wallpaper is current")
+ except (FileNotFoundError, ValueError):
+ pass
+
+ set_wallpaper(random.choice(wallpapers), args.no_smart)