Skip to content

Honour XDG_CONFIG_HOME on every platform - #18

Merged
rvben merged 1 commit into
rvben:mainfrom
joshuataylor:feature/xdg-config-dir
Nov 12, 2026
Merged

rvben merged 1 commit into
rvben:mainfrom
joshuataylor:feature/xdg-config-dir

Conversation

@joshuataylor

Copy link
Copy Markdown
Contributor

Neat tool, means I didn't have to hack together something myself. 🎉

On macOS, I set XDG_CONFIG_HOME, and this wasn't respected by unifi-cli, and I really wanted it to, so I made it so. I also added a bunch of tests.

If you want to change anything, feel free, hoping this helps.

Also noticed completions fish --install on macOS wrote to Application Support/fish/completions, which fish never reads, it now writes to $XDG_CONFIG_HOME/fish/completions, or ~/.config/fish/completions when the variable is unset. (I use zsh, but 🤷 )

The config file was found through `dirs::config_dir()`, which ignores `XDG_CONFIG_HOME` on macOS and always returns `~/Library/Application Support`.

When `XDG_CONFIG_HOME` is set to an absolute path, use `$XDG_CONFIG_HOME/unifi/config.toml` instead.

Empty and relative values are ignored, as the [XDG Base Directory spec](https://specifications.freedesktop.org/basedir/) requires.

If the XDG file doesn't exist yet but the platform default does, keep reading the platform file so an existing config isn't dropped. `config init` always writes to the XDG path, seeding it with the profiles from the platform file and leaving that file in place.

Noticed `completions fish --install` used `dirs::config_dir()` as well, so on macOS it wrote to `Application Support/fish/completions`, which fish never reads.

It now writes to `$XDG_CONFIG_HOME/fish/completions`, or `~/.config/fish/completions` when the variable is unset.
@rvben
rvben force-pushed the feature/xdg-config-dir branch from bc9bdff to 7ba6a98 Compare November 12, 2026 10:28
@rvben
rvben enabled auto-merge (squash) November 12, 2026 10:28
@rvben
rvben merged commit 40989d9 into rvben:main Nov 12, 2026
10 checks passed

rvben commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Thanks for the contribution and the tests! Merged and released in v0.5.1

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.

2 participants