tinted-theming / tinty

A base16 and base24 color scheme manager
MIT License
58 stars 5 forks source link

[Bug report] Mac not using `.config` for default config directory #62

Closed phantomwhale closed 1 month ago

phantomwhale commented 1 month ago

Describe the bug

The default configuration file location on MacOS isn't working as per the documentation, it's using a MacOS Library location that isn't commonly used for CLI config files

(Unsure if a bug or an issue - apologies if this isn't in the best category!)

Expected behavior

Assuming that XDG_CONFIG_HOME env variable has not been set, the default configuration file location should be ~/.config/tinted-theming/tinty/config.toml

Screenshots

CleanShot 2024-09-25 at 17 29 11

System

Operating system: MacOS 14.5

Terminal: Kitty

Minimal configuration file

Ironically, I don't think the config file matters here, given tinty isn't finding / using it 😬

Additional context

I did a little digging around to see if I could understand this better.

I found a similar problem / solution in another Rust project here - https://github.com/nushell/nushell/pull/8682

My understanding is the directories library has drawn the line under this as "not a bug" - https://github.com/dirs-dev/directories-rs/issues/47#issuecomment-478337412

Nonetheless, I don't seem to have hit this issue with other tooling; and note the above PR moved to another directory crate to remedy this issue.

I'm not a Rust developer, so hard for me to dig much deeper, but thanks for your review and consideration

phantomwhale commented 1 month ago

Briefly thought - oh wait, why don't I just set the XDG var as a simple workaround!

But apparently this doesn't work either:

CleanShot 2024-09-25 at 17 37 20

EDIT - oh right, reading the issue shared above, it was never going to work. Looks like the dirs project is locked into that being the "right and only place" for Mac CLI config to live, and no support for config in home dirs. Can't say I understand how they've come to that hard line, but it's certainly not a "developer dotfiles"-compatible approach.

JamyGolden commented 1 month ago

Thanks for creating the issue. I will create an override for this dirs behaviour since your idea above makes sense to me: If XDG vars are set, it should pick that up and use that. I'll work on it this week and let you know when I've added that.

What you can do in the meantime is to add this in your .zshrc file:

config_path="$XDG_CONFIG_HOME/tinted-theming/tinty/config.toml"
data_path="$XDG_DATA_HOME/tinted-theming/tinty"

alias tinty="tinty --config=\"$config_path\" --data-dir=\"$data_path\""

unset config_path data_path

--config and --data-dir allows you to override the default values used by dirs

phantomwhale commented 1 month ago

Ah yeah, didn't think about setting an alias! (line 3 needs the prefix alias incase anyone else is copying the snippet above)

Don't think it's typical for MacOS developers to have the XDG_* vars set, so I dare say others might come across this issue; certainly many other tools I use (bat, neovim, yabai, kitty, gh) all seem to "default" to use ~/.config without any extra setup.

So ideally the Mac version of the tool would just default to use .config as well (which appears to be the behaviour of the etcetera Rust libarary).

But the above workaround and an override of dirs to pickup the XDG_ vars would work just as well for me; can't see any harm in having those env vars set in general.

Thanks for your help, much appreciated, and looking forward to pull out a bunch of ansible (to clone base16 git repos) and dotfiles and replace it all with tinty!

JamyGolden commented 1 month ago

I've created a PR here, I'll leave it up for a day or so and merge if no one has any comments.

JamyGolden commented 1 month ago

Just merged, let me know if you run in to any bugs with it!