diff --git a/README.md b/README.md index 229224b..f8ecc75 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Selections are saved to `$XDG_CACHE_HOME/bw-menu/history.json` (defaults to `~/. ## Configuration -Config file location: `$XDG_CONFIG_HOME/bw-menu/config.yaml` (defaults to `~/.config/bw-menu/config.yaml`). +Config file location: `$XDG_CONFIG_HOME/bw-menu/config.yaml` (or `config.yml`), defaults to `~/.config/bw-menu/config.yaml`. ```yaml keybindings: diff --git a/src/bw_menu/config.py b/src/bw_menu/config.py index f4b98ff..c3a5b4e 100644 --- a/src/bw_menu/config.py +++ b/src/bw_menu/config.py @@ -17,14 +17,19 @@ class Config: ) -def __config_path() -> Path: +def __config_path() -> Path | None: config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")) - return Path(config_dir) / "bw-menu" / "config.yaml" + base = Path(config_dir) / "bw-menu" + for ext in ("yaml", "yml"): + path = base / f"config.{ext}" + if path.exists(): + return path + return None def load() -> Config: path = __config_path() - if not path.exists(): + if path is None: return Config() try: