Allow organization of wallpaper directory
This commit is contained in:
parent
4d44d82d4c
commit
fd62f649d0
1 changed files with 9 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
"""Script to update the wallpaper"""
|
"""Script to update the wallpaper"""
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
from collections.abc import Iterator
|
||||||
from json import dumps, loads
|
from json import dumps, loads
|
||||||
from math import ceil, floor, isnan, nan
|
from math import ceil, floor, isnan, nan
|
||||||
from os import environ
|
from os import environ
|
||||||
|
@ -70,11 +71,18 @@ class Wallpaper(Background):
|
||||||
if len(stringified) != cls._cache.write_text(stringified):
|
if len(stringified) != cls._cache.write_text(stringified):
|
||||||
raise Exception("Did not fully write blue light cache to file")
|
raise Exception("Did not fully write blue light cache to file")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _files(cls) -> Iterator[Path]:
|
||||||
|
for (root, _, files) in cls._wallpapers.walk():
|
||||||
|
if root.name != "ignore":
|
||||||
|
for file in files:
|
||||||
|
yield root / file
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def available(cls) -> "OrderedSet[Background]":
|
def available(cls) -> "OrderedSet[Background]":
|
||||||
cache = cls._read_cache()
|
cache = cls._read_cache()
|
||||||
modified = False
|
modified = False
|
||||||
wallpapers = {str(path): Wallpaper(path) for path in cls._wallpapers.iterdir()}
|
wallpapers = {str(path): Wallpaper(path) for path in cls._files()}
|
||||||
for wallpaper in wallpapers.values():
|
for wallpaper in wallpapers.values():
|
||||||
cached = cache.get(str(wallpaper._path))
|
cached = cache.get(str(wallpaper._path))
|
||||||
if cached is None or isnan(cached):
|
if cached is None or isnan(cached):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue