You are not logged in.

#1 2022-10-05 07:55:31

diniamo
Member
Registered: 2022-06-15
Posts: 107

Setting XDG directories messes up everything

I'm trying to set my XDG directories in /etc/environment like this:

XDG_DATA_HOME='$HOME/.local/share'
XDG_CONFIG_HOME='$HOME/.config'
XDG_STATE_HOME='$HOME/.local/state'
XDG_CACHE_HOME='$HOME/.cache'

After doing so, my Gnome settings (and some other stuff as well, I presume) get reset. How can I make sure all the appropriate files get moved to the new locations?
I probably messed something up, as a folder named $HOME was created in my home directory as well.

I'm trying to set these variables in the first place to do the stuff proposed by xdg-ninja.

Offline

#2 2022-10-05 09:16:04

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,754

Re: Setting XDG directories messes up everything

All of these are the logical default and should not need to be explicitly set.

Your problem is that $HOME is not expanded to your real home dir if defined like that.  you need to use @{HOME} , and in general a different format if you use /etc/environment, like:

XDG_DATA_HOME  DEFAULT=@{HOME}/.local/share

https://wiki.archlinux.org/title/Enviro … ng_pam_env

Last edited by V1del (2022-10-05 09:19:59)

Offline

#3 2022-10-05 10:23:41

diniamo
Member
Registered: 2022-06-15
Posts: 107

Re: Setting XDG directories messes up everything

Hmm, thanks a lot, another issue created because of my inability to read...
But why won't

echo $XDG_CONFIG_HOME

display anything? xdg-ninja also says that they are still not set.

Also, where should I be putting the variables suggested by xdg-ninja? It's not clear to me.

Last edited by diniamo (2022-10-05 10:26:26)

Offline

#4 2022-10-05 11:05:05

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,754

Re: Setting XDG directories messes up everything

Apparently to do them in that way you need to put them into /etc/security/pam_env.conf and /etc/environment doesn't do any variable expansion at all.

Offline

#5 2022-10-05 13:48:01

seth
Member
Registered: 2012-09-03
Posts: 51,473

Re: Setting XDG directories messes up everything

where should I be putting the variables suggested by xdg-ninja?

"Not"

V1del wrote:

All of these are the logical default and should not need to be explicitly set.

https://github.com/b3nj5m1n/xdg-ninja/issues/8

i tHiNk mOsT PeOpLe uSiNg tHiS ToOl aRe pRoBaBlY ExPlIcItLy eXpOrTiNg tHe xDg vArS

https://specifications.freedesktop.org/ … atest.html

If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.

Should should not be used in a spec but since we're still not living in a shouldland, the xdg-ninja approach is off and silly.

There'll be other processes (I'm pretty sure to have seen that) that will set custom XDG paths unless the XDG variable is set and then their behavior will be undesired because you explicitly configured the default.
Abandon this and don't do random stuff w/o understanding why and just because a random tool tells you so.

Offline

#6 2022-10-05 14:50:45

diniamo
Member
Registered: 2022-06-15
Posts: 107

Re: Setting XDG directories messes up everything

Hmm, okay, I just thought it would be a good idea to have all these files in their appropriate directories instead of the home one.

Offline

#7 2022-10-05 15:00:05

seth
Member
Registered: 2012-09-03
Posts: 51,473

Re: Setting XDG directories messes up everything

One doesn't have anything to do w/ the other.
You're trying to configure teh XDG paths to their defaults, on advice of xdg-ninja. But that's nonsense and related to a buggy implementation of that particular tool.
Whether or not other programs use the XDG paths or just put everything into ~/.somerc is unrelated and only depends on that very program.
You cannot make some "legacy" code that uses pre-XDG ~/.stuff use the XDG_CONFIG_HOME just by exporting that.

Offline

#8 2022-10-05 15:04:27

diniamo
Member
Registered: 2022-06-15
Posts: 107

Re: Setting XDG directories messes up everything

Ohh okay, I get your point then...

But one question remains unanswered:

diniamo wrote:

Also, where should I be putting the variables suggested by xdg-ninja? It's not clear to me.

(This doesn't refer to the xdg variables)

Offline

#9 2022-10-05 15:10:49

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,754

Re: Setting XDG directories messes up everything

As mentioned in post #4 if you wanted to set them with the pam_env approach in /etc/security/pam_env.conf in the format I posted. Otherwise look at the other options in the Environment variables page, /etc/profile is a common one that should get parsed by the majority of login utilities where you can use the standard

 export XDG_CONFIG_HOME=${HOME}/.config

understood by most shells.

Offline

#10 2022-10-05 15:15:25

seth
Member
Registered: 2012-09-03
Posts: 51,473

Re: Setting XDG directories messes up everything

There's no generic answer to "where do I add environment variables" as the only approapriate answer is "into the right context"
https://wiki.archlinux.org/title/Environment_variables

It's also important to understand that any running shell will not be affected by edits to /etc/profile*, /etc/environment, /etc/security/pam_env.conf, ~/.bashrc etcetc.
You can export them directly to a running shell or just in the context of a spawned process, though - eg. using "env" or shell specific syntax.

Offline

Board footer

Powered by FluxBB