"""Optional user configuration in ~/.config/hello-hut/config.toml.""" import os try: import tomllib except ModuleNotFoundError: # Python < 3.11 tomllib = None def config_path(): base = os.environ.get("XDG_CONFIG_HOME") or os.path.join(os.environ["HOME"], ".config") return os.path.join(base, "hello-hut", "config.toml") def load_config(path=None): """Return the parsed configuration, or an empty dict if there is none.""" path = path or config_path() if not path or tomllib is None or not os.path.exists(path): return {} with open(path, "rb") as f: return tomllib.load(f)