ADD configuration loading from user and default config files

This commit is contained in:
2025-12-18 15:16:19 +00:00
parent 3e2efe06b1
commit 6105a59a1d
4 changed files with 23 additions and 7 deletions

View File

@@ -1,7 +1,18 @@
from pathlib import Path
import os, json
import os, json, tomllib
from importlib import resources
APP_NAME = "rewind"
USER_CONFIG = Path.home() / ".rewind.toml"
def load_config() -> dict:
if USER_CONFIG.exists():
with USER_CONFIG.open("rb") as f:
return tomllib.load(f)
# fallback to packaged default
with resources.files("rewind").joinpath("config.toml").open("rb") as f:
return tomllib.load(f)
def state_dir() -> Path:
base = os.path.expanduser("~/.local/share")