Dotfiles/desktopenvs/hyprdrive/station-bar/config.py

32 lines
860 B
Python

"""Tiny user-editable config file: ~/.local/state/station-bar/config.json.
Read once at startup (main.py); the flag is passed into StationBar's
constructor rather than polled, so a change takes effect on the next
station-bar-start.sh restart, not live. Same pattern as orbit-menu/horizon-
dock/astro-menu's config.py.
"""
from __future__ import annotations
import json
from paths import CONFIG_FILE, ensure_dirs
_DEFAULTS = {"hologram": True}
def _load() -> dict:
try:
data = json.loads(CONFIG_FILE.read_text())
except (FileNotFoundError, json.JSONDecodeError):
data = {}
merged = {**_DEFAULTS, **data}
if not CONFIG_FILE.exists():
ensure_dirs()
CONFIG_FILE.write_text(json.dumps(merged, indent=2) + "\n")
return merged
def hologram_enabled() -> bool:
return bool(_load().get("hologram", True))