"""Tiny user-editable config file: ~/.local/state/astro-menu/config.json. Same pattern as orbit-menu/config.py and horizon-dock/config.py. Deliberately separate from settings.py's Settings class: that one persists quad enable/ feature toggles and favorites (module-scoped, read via ctx.feature()), while this is a single whole-window flag read once at startup. "layouts" narrows/customises the workspace-layout picker in the taskbar panel (ui/taskbar.py) on top of what hypr/layouts auto-discovers and writes to ~/.cache/astro-menu/layouts.json: "enabled": list of layout names to offer, in that order (tab order follows it) — omit/null to show everything hypr/layouts discovered. "overrides": {layout_name: {partial layout spec}} shallow-merged onto the discovered spec for that layout — e.g. trim "dirs" to fewer directions, or set "fit_method"/"stepper" to false to hide those controls for that layout, without touching its .lua file. Example: "layouts": { "enabled": ["scrolling", "master", "monocle"], "overrides": {"scrolling": {"dirs": ["down", "right"]}} } """ from __future__ import annotations import json from paths import CONFIG_FILE, ensure_dirs _DEFAULTS = {"hologram": True, "layouts": {"enabled": None, "overrides": {}}} 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 apply_layout_config(layouts: list[dict]) -> list[dict]: """Filter/reorder/override the layouts hypr/layouts discovered, per the "layouts" config key. `layouts` is the parsed layouts.json (or its hardcoded fallback) — see Taskbar._load_layouts.""" cfg = _load().get("layouts") or {} enabled = cfg.get("enabled") overrides = cfg.get("overrides") or {} by_name = {ly["name"]: ly for ly in layouts} names = enabled if enabled else [ly["name"] for ly in layouts] out = [] for name in names: ly = by_name.get(name) if ly is None: continue # config names a layout hypr/layouts never discovered out.append({**ly, **overrides.get(name, {})}) return out