Make manual pin permanent instead of a 5-minute timeout
"Show X now" now persists indefinitely (survives restarts too, it's in config.json) instead of auto-expiring back to rotation after 5 minutes. Implemented by reusing the existing rotation.enabled flag rather than a separate scheduler-side timer: pinning a screen sets rotation.enabled=False and records which screen in a new pinned_screen config field. Re-enabling rotation -- either the "Resume automatic" button or just checking "Enabled" again on the Rotation settings page -- clears the pin and resumes normal cycling either way. Navidrome priority is unchanged: still checked first, still preempts a pin the instant something's playing, same as it already preempted rotation. Verified end-to-end: pin persists across many scheduler ticks (previously would have reverted after 5 min), both resume paths (button and settings checkbox) clear it correctly.
This commit is contained in:
1 parent
c0192fca7a
commit
15c7c38d86
4 files changed
+49
-25
No files matched your search
@@ -42,6 +42,7 @@ class Config:
|
||||
data["rotation"].setdefault("interval_minutes", DEFAULT_ROTATION["interval_minutes"])
|
||||
data["rotation"].setdefault("enabled", DEFAULT_ROTATION["enabled"])
|
||||
data.setdefault("navidrome_priority", True)
|
||||
data.setdefault("pinned_screen", None)
|
||||
data.setdefault("settings", {})
|
||||
for screen_id, screen in screens.items():
|
||||
data["settings"].setdefault(screen_id, {})
|
||||
@@ -81,6 +82,30 @@ class Config:
|
||||
def set_rotation(self, screens: list[str], interval_minutes: int, enabled: bool) -> None:
|
||||
with self._lock:
|
||||
self._data["rotation"] = {"screens": screens, "interval_minutes": interval_minutes, "enabled": enabled}
|
||||
if enabled:
|
||||
# Re-enabling rotation (e.g. via the settings checkbox)
|
||||
# supersedes any manual pin -- that's the intended way to
|
||||
# get back to automatic switching.
|
||||
self._data["pinned_screen"] = None
|
||||
self.save()
|
||||
|
||||
def get_pinned_screen(self) -> str | None:
|
||||
with self._lock:
|
||||
return self._data.get("pinned_screen")
|
||||
|
||||
def pin_screen(self, screen_id: str) -> None:
|
||||
"""Pin a screen indefinitely -- turns rotation off so it doesn't
|
||||
fight with the pin. Stays until the pin is explicitly cleared or
|
||||
rotation is re-enabled (settings checkbox, or resume_rotation())."""
|
||||
with self._lock:
|
||||
self._data["pinned_screen"] = screen_id
|
||||
self._data["rotation"]["enabled"] = False
|
||||
self.save()
|
||||
|
||||
def resume_rotation(self) -> None:
|
||||
with self._lock:
|
||||
self._data["rotation"]["enabled"] = True
|
||||
self._data["pinned_screen"] = None
|
||||
self.save()
|
||||
|
||||
def get_navidrome_priority(self) -> bool:
|
||||
|
||||
Reference in new issue
Block a user