gmailctl icon indicating copy to clipboard operation
gmailctl copied to clipboard

Move config directory (& state?) to XDG paths

Open paravoid opened this issue 3 years ago • 3 comments

(Thanks for writing gmailctl and releasing it as open source!)

The proliferation of dot files/directories in users' home directories, the poor portability of paths like ".app" as well as the mixing of config and state are problems that are being addressed by the (now ubiquitous) freedesktop.org XDG base directory specification. This specifies directories like ~/.config/gmailctl (and possibly ~/.local/share/token.json) on Linux systems, and equivalent paths on OS X & Windows, unless overriden by environment variables. It'd be great if gmailctl moved its paths to match the XDG specification.

The implementation should be easy enough, but there are multiple Go libraries implementing this as well¹:

  • https://github.com/shibukawa/configdir
  • https://github.com/openpeedeep/xdg
  • https://github.com/kyoh86/xdg
  • https://code.launchpad.net/go-xdg
  • https://github.com/adrg/xdg

(All but the last are used enough to exist as a Debian package, if that matters)

1: There is a certain irony in a proliferation of libraries trying to address a proliferation problem…

paravoid avatar Sep 27 '20 15:09 paravoid

I agree that this would be an improvement for new users.

The problem is the migration path for existing installations. I would avoid moving their files around, as many use symlinks or rely on the config directory to not change. Perhaps the only safe way to do this would be to always check if $HOME/.gmailctl is empty, and if so use the new path.

mbrt avatar Sep 29 '20 09:09 mbrt

Perhaps the only safe way to do this would be to always check if $HOME/.gmailctl is empty, and if so use the new path.

I've submitted a PR for this: https://github.com/mbrt/gmailctl/pull/393

In theory it could be improved by using a library, but it's only a 4 additional lines of code to avoid the primary issue of requiring a folder directly in the home directory. Seeing as this issue has the most upvotes, I think it would be a welcome improvement over the existing behaviour!

lgarron avatar Mar 21 '24 06:03 lgarron

I'm inclined at this point to say that this is a nice to have but will probably not be implemented. The risk of breaking existing users, plus introducing a weird behavior by which in certain situations the old directory is considered and in others we get the standard behavior, for me are not worth the trouble.

This can also be easily solved by the end user by simply aliasing gmailctl:

alias gmailctl='gmailctl --config=$HOME/.config/gmailctl'

I'll keep this open for now as I want to take another look in case there's an easy and clear to understand solution I'm missing.

mbrt avatar Mar 23 '24 17:03 mbrt