31 lines
836 B
Python
31 lines
836 B
Python
"""Tiny user-editable config file: ~/.local/state/orbit-menu/config.json.
|
|
|
|
Currently a single toggle. Read once at startup (main.py); the satellites flag
|
|
is 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}
|
|
|
|
|
|
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))
|