testsAndMisc/python_pkg/wallpaper_rotator/_context.py
Krzysztof kuhy Rudnicki d502580e3f Dark wallpaper rotator: new style every 3 h
Six text-free styles (gradient, flow/Voronoi, habit heatmap, shutdown
clock, Earth day/night, plasma) replace the white i3 root. A 15-minute
systemd user timer picks a new random style per monitor every 3 hours,
unlike its previous one and the other monitor's; live styles refresh in
between. Also syncs i3/config with the live config and prunes the
oldest evidence artifact for the 60-file cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWX51FMD58yKUC1eYWf
2026-11-11 16:31:06 +01:00

37 lines
1.0 KiB
Python

"""Inputs a style may read, injectable for tests."""
from __future__ import annotations
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
DEFAULT_CACHE = Path.home() / ".cache" / "wallpaper_rotator"
@dataclass(frozen=True)
class RenderContext:
"""Where the data-driven styles read from, and what time it is.
Attributes:
now: Current local time (timezone-aware).
data_home: ``~/.local/share``, holding the guards' ledgers.
earth_dir: Holds ``day.jpg`` and ``night.jpg`` (see install.sh).
shutdown_conf: screen-locker's schedule file.
"""
now: datetime
data_home: Path
earth_dir: Path
shutdown_conf: Path
@classmethod
def live(cls) -> RenderContext:
"""Build the context for the running desktop."""
return cls(
now=datetime.now().astimezone(),
data_home=Path.home() / ".local" / "share",
earth_dir=DEFAULT_CACHE / "earth",
shutdown_conf=Path("/etc/shutdown-schedule.conf"),
)