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

Honor the XDG basedir specification #525

Closed
piegamesde opened this issue Sep 13, 2021 · 5 comments
Closed

Honor the XDG basedir specification #525

piegamesde opened this issue Sep 13, 2021 · 5 comments
Milestone

Comments

@piegamesde
Copy link

Is your feature request related to a problem? Please describe

Currently, the search path for potential configuration files is hard-coded.

Describe the solution you'd like

Do an environment variable lookup as described in the XDG base directory specification to determine the appropriate location(s).

Additional context

Related to JoseExposito/gnome-shell-extension-x11gestures#21, and probably supersedes #510.

@JoseExposito
Copy link
Owner

Thanks for the bug report.

$XDG_CONFIG_DIRS looks like the variable to use. Could you copy and paste the value of that variable on NixOS, please?

I'll test with a similar value on my OS to make sure it solves the problem.

@piegamesde
Copy link
Author

You want $XDG_CONFIG_DIRS for reading config, and $XDG_CONFIG_HOME if the application wants to edit the configuration on a user level.

$XDG_CONFIG_DIRS=/etc/xdg:/root/.nix-profile/etc/xdg:/etc/profiles/per-user/root/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg

Note that most of these entries symlink to the same folder and are thus redundant, but this is not necessarily always the case. Furthermore, many applications are wrapped and the wrapper script sets some environment variables. Touchégg for example will probably get an entry pointing to its install location, /nix/store/SOMEVERLYONGHASH-touchegg-VERSION/etc/xdg.

@JoseExposito
Copy link
Owner

Cool, thanks for the example.

Touchégg for example will probably get an entry pointing to its install location, /nix/store/SOMEVERLYONGHASH-touchegg-VERSION/etc/xdg.

Will the GNOME Shell extension and Touché have the same path in their $XDG_CONFIG_DIRS variable?

If not, the issues running them on NixOS will remain.

@piegamesde
Copy link
Author

If not, the issues running them on NixOS will remain.

Yes but they'll be a lot more manageable. This is a really common problem, so we have tooling to automatically wrap a binary while setting some environment variables. This is way less painful than having to manage a patch set.

JoseExposito added a commit that referenced this issue Oct 17, 2021
If $XDG_CONFIG_DIRS is set, check if the config is present in one of
those directories. Otherwise, fallback to /etc/xdg, as in the spec:

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Finally, fallback to SYSTEM_CONFIG_FILE_PATH for backwards compatibility.

Fix #477 and #525
@JoseExposito
Copy link
Owner

Hi, sorry for the delay fixing this. Here is the fix: #535

Now Touchégg uses both XDG_CONFIG_HOME and XDG_CONFIG_DIRS.

@JoseExposito JoseExposito added this to the 2.0.12 milestone Oct 17, 2021
JoseExposito added a commit that referenced this issue Oct 17, 2021
If $XDG_CONFIG_DIRS is set, check if the config is present in one of
those directories. Otherwise, fallback to /etc/xdg, as in the spec:

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Finally, fallback to SYSTEM_CONFIG_FILE_PATH for backwards compatibility.

Fix #477 and #525
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

2 participants