Repository navigation
fix(config): honor XDG_CONFIG_HOME on all platforms (#176) - #183
Open
liziye627-design wants to merge 1 commit into
Open
liziye627-design wants to merge 1 commit into
liziye627-design wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(config): honor XDG_CONFIG_HOME on all platforms
Closes #176
What
config_path()useddirs::config_dir()only. On Linux that already followsXDG_CONFIG_HOME, but on macOS it always returns~/Library/Application Support, soXDG_CONFIG_HOMEwas ignored there.Lookup order is now:
$XDG_CONFIG_HOME/abtop/config.tomlifXDG_CONFIG_HOMEis set and non-emptydirs::config_dir()/abtop/config.toml(unchanged previous behaviour)The logic is a pure helper
resolve_config_path(xdg_config_home, fallback), andconfig_path()is still the single path used by bothload_configandsave_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_HOMEand 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
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_homefailed 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 insrc/collector/claude.rs,mcp.rsandopencode.rs, which already exist onmainand 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.