Accept both .yaml and .yml config file extensions

This commit is contained in:
Navid Sassan 2026-02-17 22:08:39 +01:00
parent fab921066a
commit 9b080f6b07
2 changed files with 9 additions and 4 deletions

View File

@ -84,7 +84,7 @@ Selections are saved to `$XDG_CACHE_HOME/bw-menu/history.json` (defaults to `~/.
## Configuration ## 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 ```yaml
keybindings: keybindings:

View File

@ -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")) 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: def load() -> Config:
path = __config_path() path = __config_path()
if not path.exists(): if path is None:
return Config() return Config()
try: try: