forked from Shinonome/caelestia-cli
wallpaper: fix when no wall
This commit is contained in:
@@ -18,4 +18,4 @@ class Command:
|
||||
elif self.args.random:
|
||||
set_random(self.args)
|
||||
else:
|
||||
print(get_wallpaper())
|
||||
print(get_wallpaper() or "No wallpaper set")
|
||||
|
||||
@@ -31,7 +31,10 @@ def check_wall(wall: Path, filter_size: tuple[int, int], threshold: float) -> bo
|
||||
|
||||
|
||||
def get_wallpaper() -> str:
|
||||
try:
|
||||
return wallpaper_path_path.read_text()
|
||||
except IOError:
|
||||
return None
|
||||
|
||||
|
||||
def get_wallpapers(args: Namespace) -> list[Path]:
|
||||
@@ -71,9 +74,9 @@ def get_thumb(wall: Path, cache: Path) -> Path:
|
||||
def get_smart_mode(wall: Path, cache: Path) -> str:
|
||||
mode_cache = cache / "mode.txt"
|
||||
|
||||
if mode_cache.exists():
|
||||
try:
|
||||
return mode_cache.read_text()
|
||||
|
||||
except IOError:
|
||||
with Image.open(get_thumb(wall, cache)) as img:
|
||||
img.thumbnail((1, 1), Image.LANCZOS)
|
||||
mode = "light" if Hct.from_int(argb_from_rgb(*img.getpixel((0, 0)))).tone > 60 else "dark"
|
||||
|
||||
Reference in New Issue
Block a user