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

Add XDG Base Directory support #161

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

pbaudoux
Copy link

@pbaudoux pbaudoux commented Jun 29, 2022

This PR adds support for XDG Base Directory Specification.

Configuration file should be stored in $XDG_CONFIG_HOME if the variable is set and $HOME/.config if not.
For backward compatibility reason, if a dotfile already exist in $HOME, then it is used.

More information here: https://wiki.archlinux.org/title/XDG_Base_Directory

@hnarayanan
Copy link
Owner

Thank you for this. Could you possibly rework this PR to be more In line with the description you have above? i.e.

If $XDG_CONFIG_HOME is set:
   use it to find the file
else:
   do what was happening before

@pbaudoux
Copy link
Author

pbaudoux commented Sep 9, 2022

Hi,

Thanks for your reply.

From the specification:

XDG_CONFIG_HOME
Where user-specific configurations should be written (analogous to /etc).
Should default to $HOME/.config.

So the behavior should be:

If $XDG_CONFIG_HOME is set:
   use it to find the file
else:
   use $HOME/.config

The idea is to centralize all config files in a single folder, by default the .config folder, and avoid hundreds of wild dotfiles in $HOME.

For backward compatibility purpose, I first check if the dotfile is present in $HOME (i.e. the user already used a previous version of shpotify), making the full pseudo-code:

If $HOME/.shpotify.cfg exist:
   use it
else if $XDG_CONFIG_HOME is set:
   use it 
else:
   use $HOME/.config (should be the case for most users)

I hope this brings some clarity to the PR.

@samuelmasuy
Copy link

I tried to introduce a way to override where shpotify finds its config file in #142, this could be less invasive, where it would be the responsibility of the end-user to say that SHPOTIFY_CONFIG_FILE=$XDG_CONFIG_HOME/shpotify/shpotify.cfg for example.

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.

None yet

3 participants