summaryrefslogtreecommitdiff
path: root/wallpaper.py
diff options
context:
space:
mode:
Diffstat (limited to 'wallpaper.py')
-rwxr-xr-xwallpaper.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/wallpaper.py b/wallpaper.py
index a940710..446c4d6 100755
--- a/wallpaper.py
+++ b/wallpaper.py
@@ -340,11 +340,13 @@ def step_save(
return saved
-def step_wallpaper(command: list[str], saved: list[Path]) -> None:
+def step_wallpaper(command: list[str], saved: list[Path], store: Path) -> None:
idx = random.randrange(len(saved))
try:
- logger.info(f"Setting wallpaper to {saved[idx]}")
- _ = subprocess.run(command + [saved[idx]], check=True)
+ perma = store / "generated_wallpaper.jpg"
+ _ = perma.open("wb").write(Path(saved[idx]).read_bytes())
+ logger.info(f"Setting wallpaper to {perma}")
+ _ = subprocess.run(command + [perma], check=True)
except Exception as e:
logger.warning(f"Could not set wallpaper: {e}")
@@ -375,7 +377,12 @@ def parse_args() -> argparse.Namespace:
help="Taste keywords for the LLM art-director prompt.",
)
wall.add_argument(
- "--output-dir", default="/tmp/wallpaper/", help="Output directory."
+ "--ephemeral-dir", default="/tmp/wallpaper/", help="Output directory."
+ )
+ wall.add_argument(
+ "--single-file-persist-path",
+ default="~/media/pictures/",
+ help="Single target for persistance.",
)
wall.add_argument(
"--target-width", type=int, default=3840, help="Final wallpaper width."
@@ -555,13 +562,17 @@ def run() -> None:
)
# 5. save to configured output directory
- saved = step_save(upscaled, Path(args.output_dir).expanduser(), now, prompt_text)
+ saved = step_save(upscaled, Path(args.ephemeral_dir).expanduser(), now, prompt_text)
for p in saved:
logger.info("Saved: %s", p.resolve())
# 6. set wallpaper
- step_wallpaper(args.set_command, saved)
+ step_wallpaper(
+ args.set_command,
+ saved,
+ Path(args.single_file_persist_path).expanduser(),
+ )
if __name__ == "__main__":