ArchLabs Linux

XDG Base Directory Specification - do you use it?

I was pointed out that my program should follow the XDG Base Directory Specification. In general I agree, but how do you guys set the environment variables - if at all? I ran through my all Linux installs, and checking all the variables, except for XDG_RUNTIME_DIR, returned None.

Here s what I get:

XDG_RUNTIME_DIR
bash: XDG_RUNTIME_DIR: command not found

Never knew it existed by the way.

Must be part of some apps or wnatever that I think of .

Try $XDG_RUNTIME_DIR. I’m also interested in $XDG_CONFIG_DIR and $XDG_DATA_DIR.

Oh, here it is:

$XDG_RUNTIME_DIR
bash: /run/user/1000: Is a directory

$XDG_CONFIG_DIR and $XDG_DATA_DIR .

These has no output to them in my install.

You might be interested in this link here;

Edit: Have a look at the 3rd answer.

Same here. OK, I’ll be checking XDG_CONFIG_HOME and XDG_DATA_HOME and replacing with ~/.config and ~/.local/share if not found. Still I’m not sure if it’s the proper attitude.

Not really. I only care of the config and data placement.

Oh ok.

something like:

export XDG_CONFIG_HOME="$HOME/.config"

in the ~/.profile or ~/.xprofile so it’s set when a user logs in. I think that is still a default environment variable for ArchLabs set in the ~/.xprofile.

I should’ve been more specific. What I actually mean is not how to set the variables, but whether your OS returns any values for XDG_CONFIG_HOME and XDG_DATA_HOME. :slight_smile:

[edit] Also: can I place the log.txt file in the data directory?

They’re blank, except for the example I gave you.

Did find this.

Alright, thanks. I’ll do something like this, just in case:

xdg_config_home = os.getenv('XDG_CONFIG_HOME')
common.config_home = xdg_config_home if xdg_config_home else os.path.join(os.getenv("HOME"), ".config/azote")

From env

XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SESSION_CLASS=user
XDG_SESSION_ID=1
XDG_SESSION_TYPE=tty
XDG_VTNR=1
1 Like

Your above snippet is sadly what we’re all stuck with given the current state of things.

Common place in my code to have a getenv wich returns either the env or a fallback if none.

1 Like

I must say I cared about the XDG specification never before. Anyway, my data migration seems to work.

From Debian buster (GNOME desktop):

empty@E485:~ $ echo $XDG_CONFIG_DIR

empty@E485:~ $

The variable is unset in a stock system.

From the XDG specification:

https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables

So leaving it unset is correct.

Thank you, and all the responders. All clear.

BTW: please, skip packaging Azote v1.7.0. There’s a bug inside, which I already fixed, but not yet released the fixed version.