import json import os class ConfigManager: def __init__(self, config_path: str = "config/config.json"): self.config_path = config_path self.config = self._load() def _load(self): if not os.path.exists(self.config_path): raise FileNotFoundError(f"Config file not found: {self.config_path}") with open(self.config_path, "r", encoding="utf-8") as f: return json.load(f) def get(self, key, default=None): """Return a top-level config key, e.g. 'Font' or 'Mode'.""" return self.config.get(key, default) def save(self): """Write any changes back to disk.""" with open(self.config_path, "w", encoding="utf-8") as f: json.dump(self.config, f, indent=2)