You are not logged in.
Hi,
I'd like to build a system that respects XDG as much as it can. I've been reading the XDG wiki in https://wiki.archlinux.org/title/XDG_Base_Directory . So, I'd like to set these variables for all the current and future users in my system:
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_RUNTIME_DIR="/run/user/$UID"
#export XAUTHORITY="$XDG_RUNTIME_DIR/Xauthority"
What I didn't find as a fact is where should be the best place to write them? I think /etc/profile.d/xdg.sh could be a good place, but I can see most of people just define them in their .bashrc or .zshenv files, and I can't understand why.
Also, I have had to comment the last file of the vars because I was unable to use gdm, nor lightdm or sddm (I was expecting to prevent the .Xauthority file to be on the user's home folder), but I think it's an issue for another post (I would be glad if someone could let me know some information about why that variable is so anoying ;-) )
Thanks a lor for your help
regards
Last edited by fueradeservicio (2024-03-17 13:09:51)
Offline
The spec seems to leave 'where to set the variables' up to the distribution/administration. As to why some users set them only in shell environments or whatever, some login scripts are sourced by display managers or DEs, or maybe they have some/no reason..
Perhaps some more familiar with these can offer better advice, but here goes.
https://wiki.archlinux.org/title/XDG_user_directories , which may already be present as a dependency of DE and applications, facilitates setting directory defaults (/etc/xdg/user-dirs.defaults).
XDG_RUNTIME_DIR should already default to /run/user/$UID.
Moving .Xauthority: There was a previous topic that may be informative. https://bbs.archlinux.org/viewtopic.php?id=229407
Last edited by espresso (2024-03-19 10:02:22)
Offline
Hi, thanks a lot for your response.
I hadn't read the "Environment_variables" wiki. It's very interesting.
When you say "XDG_RUNTIME_DIR should already default to /run/user/$UID" you are saying that I don't need to export that env variable, as by default it's already done, right? If that's true, "who/what" is setting that variable?
Regarding Xauthority and SDDM, I use GDM, and it stops working fine when I set that env variable to $XDG_RUNTIME_DIR/Xauthority. I'd like to know why, but I would need some advices in order to try to "debug" why it doesn't work as expected. What kind of files to look for and read... Actually, I would use any display manager that respects the xdm standard, but I have tried SDDM, gdm and lightdm, and for some reasons they weren't able to open my user's sessions. If somebody could let me know what filex to inspect, I could try to do some research.
Thanks a lot for your response, and thanks in advance for further help from anybody
Regards
Last edited by fueradeservicio (2024-03-16 20:54:41)
Offline
The spec seems to leave 'where to set the variables' up to the distribution/administration. As to why some users set them only in shell environments or whatever, maybe they are less bothered by the implications, or have their own reasons or none in particular.
Perhaps some more familiar with these can offer better advice, but here goes.
https://wiki.archlinux.org/title/XDG_user_directories , which may already be present as a dependency of DE and applications, facilitates setting directory defaults (/etc/xdg/user-dirs.defaults).
Alternatively, https://wiki.archlinux.org/title/Enviro … ng_pam_env allows defaults and use of HOME and SHELL; although I'm not aware of it supporting drop-in configuration files like the systemd method, https://wiki.archlinux.org/title/Enviro … s#Per_user
XDG_RUNTIME_DIR should already default to /run/user/$UID.
Moving .Xauthority: There was a previous topic that may be informative. https://bbs.archlinux.org/viewtopic.php?id=229407
I was thinking that, as the "Environment_variables" link you provided states, it should be a better idea to define the XDG variables in the /etc/environment file and not in /etc/profile.d, right? And, in case that any user need to set a different value for these vars, it wouldn't be any problem if she/he defines them in their personal config files.
I'm now starting to realize that it's not so easy to use the correct places to build a XDG system...
Offline
When you say "XDG_RUNTIME_DIR should already default to /run/user/$UID" you are saying that I don't need to export that env variable, as by default it's already done, right? If that's true, "who/what" is setting that variable?
Yes, and XDG_RUNTIME_DIR is set by default through pam_systemd. https://wiki.archlinux.org/title/XDG_Base_Directory
I was thinking that, as the "Environment_variables" link you provided states, it should be a better idea to define the XDG variables in the /etc/environment file and not in /etc/profile.d, right?
/etc/profile.d is just for login shells; https://wiki.archlinux.org/title/Enviro … tion_files
That leaves at least the other methods mentioned earlier.
And, in case that any user need to set a different value for these vars, it wouldn't be any problem if she/he defines them in their personal config files.
Generally no problem, as that is intended possible scenario: ~/.config/user-dirs.dirs or systemd user environment.
Last edited by espresso (2024-03-19 10:03:18)
Offline
There is no need to set those variables explicitly, the values listed are the assumed defaults.
Offline
Thanks to both for your answers. I think my doubts are already solved
Should I solve this post anywhere? I can't see any button to close the trhead
Regards!
Offline
You can mark threads '[SOLVED]' by editing your initial post subject that way.
Regards!
Offline
and what is the solution?
Ukrainian
Offline
Actually, the solution is that everything dependns on what you are trying to achieve...
What dop you need?
Offline
Actually, what does the title say.
Ukrainian
Offline
You need to be clear about which parts of the system those variables you want to define should affect. For example, if only at the shell command level, or at the Xwindows level, etc... The closest thing to enabling those variables globally and affecting practically all system applications seems to be using PAM or systemd files, or at least that's what I have understood. However, since it's not as simple as writing all the variables in a single file, I have decided to write each group of variables in their respective places (zsh, xorg, etc...).
Offline