Skip to content

fix(config): honor XDG_CONFIG_HOME on all platforms (#176) - #183

Open
liziye627-design wants to merge 1 commit into
graykode:mainfrom
liziye627-design:fix/xdg-config-home-176
Open

liziye627-design wants to merge 1 commit into
graykode:mainfrom
liziye627-design:fix/xdg-config-home-176

Conversation

@liziye627-design

Copy link
Copy Markdown

fix(config): honor XDG_CONFIG_HOME on all platforms

Closes #176

What

config_path() used dirs::config_dir() only. On Linux that already follows XDG_CONFIG_HOME, but on macOS it always returns ~/Library/Application Support, so XDG_CONFIG_HOME was ignored there.

Lookup order is now:

  1. $XDG_CONFIG_HOME/abtop/config.toml if XDG_CONFIG_HOME is set and non-empty
  2. otherwise dirs::config_dir()/abtop/config.toml (unchanged previous behaviour)

The logic is a pure helper resolve_config_path(xdg_config_home, fallback), and config_path() is still the single path used by both load_config and save_theme, so loading and saving can't diverge. The README "Configuration" section now documents the lookup order.

Note for macOS users: anyone who sets XDG_CONFIG_HOME and keeps their config in ~/Library/Application Support/abtop/ will now get the XDG location instead. That's what the issue asks for, but say so if you'd prefer a fallback that also checks the old file.

Tests

  • 4 new unit tests on resolve_config_path (XDG set, XDG empty, XDG unset, no base dir). They take the env value and fallback as arguments and have no #[cfg(target_os)], so they run on Linux CI. config_path_prefers_xdg_config_home failed before the fix and passes after.
  • cargo test: all pass (226 unit + 1 other).
  • cargo clippy --all-targets -- -D warnings: clean.
  • cargo fmt --check: no diffs in the files this PR touches. It does report diffs in src/collector/claude.rs, mcp.rs and opencode.rs, which already exist on main and are left alone.

Only unit-tested on Linux (rustc 1.95.0). There was no real macOS verification. I haven't run the binary on a Mac.


Drafted with AI assistance; the tests above were run locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect XDG_CONFIG_HOME on macOS when resolving config.toml

1 participant