Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration files should be stored in $XDG_CONFIG_HOME (by default at ~/.config) #558

Open
nagromc opened this issue Sep 22, 2021 · 9 comments

Comments

@nagromc
Copy link

nagromc commented Sep 22, 2021

Is your feature request related to a problem? Please describe.

I strive to have a clean home directory, but there are many files related to WakaTime in ~:

Describe the solution you'd like to see

A lot of softwares find their configuration in $XDG_CONFIG_HOME (by default at ~/.config), which helps to have a less cluttered ~.

WakaTime could use the same convention to place the configuration files such as .wakatime.cfg in $XDG_CONFIG_HOME/wakatime (which would be ~/.config/wakatime by default), and data files such as .wakatime.db in $XDG_DATA_HOME/wakatime or $XDG_CACHE_HOME/wakatime.

Describe alternatives you've considered

Another solution would be to group them in a new directory such as ~/.wakatime.

Additional context

This feature request describes the behavior in a Unix environment, but macOS and Windows have their own conventions, even if the XDG Base Directory Specification leaks on them a little. I let you choose what suits the most for those platforms.

@alanhamlett
Copy link
Member

This is something we've been wanting to do for a while. Let's use:

  • Unix: $XDG_CONFIG_HOME/wakatime/
  • Mac: $HOME/.wakatime/
  • Windows: $HOME/.wakatime/

Some of the editor extensions already use $HOME/.wakatime/ for the wakatime-cli location.

@nagromc
Copy link
Author

nagromc commented Sep 23, 2021

This seems reasonable to me 👍

@viggo-gascou
Copy link

viggo-gascou commented Aug 8, 2022

Status on this? Would like to declutter my home directory as well 😅

Also if I set the various $XDG_XXXX_HOME variables on a Mac would WakaTime 'respect' it or always put it in $HOME/.wakatime/?

And lastly does setting $WAKATIME_HOME only apply to .wakatime.cfg or does it also apply to the log and other files that OP mentioned?

Thanks!

@kfdm
Copy link

kfdm commented Aug 9, 2022

On MacOS as well, I think it would be better to default to the XDG_CONFIG_HOME spec and keep the user's HOME tidy. I would imagine there is a go library somewhere that handles most of this already 🤔

@alanhamlett
Copy link
Member

go library somewhere that handles most of this already

Each plugin uses a different language so we'll have to implement it in multiple languages, unless we use wakatime-cli for setting the api key instead of writing the file directly from the plugins. The main thing is to make it backwards compatible so the plugins/wakatime-cli detects a config file in $HOME and moves it to the new location if one doesn't already exist there.

@sellout
Copy link

sellout commented Oct 14, 2022

I think the db and log files should go in $XDG_STATE_HOME/wakatime/ (or $XDG_CACHE_HOME/wakatime/ if they can be regenerated), not $XDG_DATA_HOME (because that’s intended to be for read-only data).

I also agree with @kfdm that the XDG locations should be used on MacOS as well.

@sellout
Copy link

sellout commented Oct 14, 2022

Oh, and I think the internal config should probably be in $XDG_CACHE_HOME, since that looks like it can be regenerated if needed. It’s not really a config file.

@nagromc
Copy link
Author

nagromc commented Dec 15, 2022

I’m not a GoLang programmer, but I just found out there are built-in functions in GoLang to abstract the OS-specific paths of the many directory usecases: config, cache, data, state, etc.

Some documentation:

Maybe you should consider to stick to these conventions after all.

@alanhamlett
Copy link
Member

Let's first move ~/.wakatime.log into ~/.wakatime/wakatime.log since that's the easiest as it's not read/used by any IDE plugins.

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

No branches or pull requests

6 participants