Dotfiles/desktopenvs/hyprlua/orbit-menu/config.py

35 lines
895 B
Python

"""Tiny user-editable config file: ~/.local/state/orbit-menu/config.json.
Read once at startup (main.py); flags are passed into OrbitMenu's constructor
rather than polled, so a change takes effect on the next orbit-menu-start.sh
restart, not live.
"""
from __future__ import annotations
import json
from paths import CONFIG_FILE, ensure_dirs
_DEFAULTS = {"satellites": True, "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 satellites_enabled() -> bool:
return bool(_load().get("satellites", True))
def hologram_enabled() -> bool:
return bool(_load().get("hologram", True))