37 lines
952 B
Python
37 lines
952 B
Python
"""Tiny user-editable config file: ~/.local/state/supersonic-booster/config.json.
|
|
|
|
Read once at startup (main.py); same pattern as the rest of the Cosmonaut Shell
|
|
suite's config.py (orbit-menu, horizon-dock, transmitter-panel).
|
|
"""
|
|
|
|
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))
|
|
|
|
|
|
def set_hologram_enabled(value: bool) -> None:
|
|
data = _load()
|
|
data["hologram"] = bool(value)
|
|
ensure_dirs()
|
|
CONFIG_FILE.write_text(json.dumps(data, indent=2) + "\n")
|