hnarayanan/shpotify

move .shpotify.cfg to ~/.credentials/shpotify.cfg

yochem opened this issue · 9 comments

It would be great if the shpotify credentials could be stored in a directory: ${HOME}/.credentials. Some applications / command line tools use this folder already, so it's possible the folder already exists. It creates a much tidier home directory and all credentials are stored in the same folder.

Let me know what you think!

From what I can tell, the current method of using ${HOME}/.shpotify.cfg is how most applications handle application specific configuration. On my laptop, I've got a lot of installed software and nothing has created a .credentials directory. Applications have instead created a specific dotfile (.gitconfig, .viminfo, etc.) or dotdirectory (.aws, .docker, etc.) to handle configuration settings.

I agree with @dmofot. It’s fairly common (if ugly) to have your home folders littered when dot files.

Also interested in a configurable config location as I try to follow the XDG standard, as many apps do https://wiki.archlinux.org/index.php/XDG_Base_Directory. Would you be amenable to a PR for this?

Yes XDG would be awesome! Didn't know about the existence of it when I created this issue.

Also, have you heard of shellcheck? It provides helpful feedback for getting a much cleaner script. Example:

image

I understand the desire to not clutter the $HOME directory, so I'm not against checking if the XDG_CONFIG_HOME is set and if not, default to the current location. But to be clear, XDG_CONFIG_HOME is a linux setting. Apple would probably tell you to put it in ~/Library/Preferences/ or ~/Library/Application Support/. The only thing I currently have in ~/.config/ is htop, which is more of a linux command line tool. Everything else is in a ~/.yourapphere directory or file.

@yochem I have not heard of that, but I'm sure @hnarayanan and others would be open to reviewing a PR.

I agree that both ideas raised here are good:

  1. The home folder is messy with dot files
  2. This shellcheck tool can improve the script

But, please do not focus too much more on (1) as this script is too small a thing to try to solve that problem. Any cleanup from (2) I will be happy to consider a PR.

XDG_CONFIG_HOME is a linux setting. Apple would probably tell you to put it in ~/Library/Preferences/ or ~/Library/Application Support/

XDG is a Linux-focused spec, however, it works perfectly on macOS. There is no reason to not use it. You want to make config files easily portable. This is the main reason for the XDG spec.

The home folder is messy with dot files

Agreed. This is part of the reason why the XDG spec exists.

please do not focus too much more on (1) as this script is too small a thing to try to solve that problem.

I disagree with this statement. If this script avoids cluttering the home directory with one more dotfile, everyone is one more dotfile closer to having an uncluttered home directory. Every large problem can be solved with incremental steps.

Here is an example bash line showing how easy this is to implement.

# Setting bash to use $XDG_CONFIG_HOME/shpotify.cfg, defaults to ~/.config/shpotify.cfg
xdg_shpotify_conf=${XDG_CONFIG_HOME:-$HOME/.config}/shpotify.cfg

And to maintain backwards compatibility, just search for ~/.shpotify.cfg first.

It doesn't make any sense to me not to give users this option.

I would also like to add that since the content of shpotify.cfg is data, it should be in $XDG_DATA_HOME, which defaults to $HOME/.local/share/. So for me, the best fitting path would be $XDG_DATA_HOME/shpotify/credentials.