Where is XDG_CONFIG_DIRS set?

If my understanding is correct, Ubuntu and variants set XDG_CONFIG_DIRS to something like

XDG_CONFIG_DIRS=/etc/xdg/xdg-$VARIANT:/etc/xdg

Then, package-provided system-wide configuration defaults in /etc/xdg can be partly overwritten eg. by packages like xubuntu-default-settings by installing configuration files in, say, /etc/xdg/xdg-xubuntu.

Where is XDG_CONFIG_DIRS set/extended?

What would be the best place to put a file containing something like

XDG_CONFIG_DIRS="/etc/xdg/xdg-mydefaults:$XDG_CONFIG_DIRS"

Some candidates are /etc/profile.d /etc/environment.d /etc/X11/Xsession.d /etc/profile.d /etc/systemd/system.conf.d /etc/systemd/user.conf.d but none of these seem to be used by ubuntu and variants for doing just this so which is the right choice?

Asked By: Gamification

||

Don’t know what’s “right”, but at least /etc/profile.d works fine for me.

$ cat /etc/profile.d/my-xdg-dir.sh
XDG_CONFIG_DIRS="/etc/xdg/xdg-mydefaults:$XDG_CONFIG_DIRS"

$ echo $XDG_CONFIG_DIRS
/etc/xdg/xdg-mydefaults:/etc/xdg/xdg-ubuntu:/etc/xdg

As regards your question where it’s set, the /etc/profile.d/xdg_dirs_desktop_session.sh file looks suspicious.

Answered By: Gunnar Hjalmarsson

It’s set in /etc/X11/Xsession.d/60x11-common_xdg_path (from package x11-common):

DEFAULT_XDG_CONFIG_DIRS='/etc/xdg'
DEFAULT_XDG_DATA_DIRS='/usr/local/share/:/usr/share/'
if [ -n "$DESKTOP_SESSION" ]; then
  # readd default if was empty
  if [ -z "$XDG_CONFIG_DIRS" ]; then
    XDG_CONFIG_DIRS="$DEFAULT_XDG_CONFIG_DIRS"/xdg-"$DESKTOP_SESSION":"$DEFAULT_XDG_CONFIG_DIRS"
  elif [ -n "${XDG_CONFIG_DIRS##*$DEFAULT_XDG_CONFIG_DIRS/xdg-$DESKTOP_SESSION*}" ]; then
    XDG_CONFIG_DIRS="$DEFAULT_XDG_CONFIG_DIRS"/xdg-"$DESKTOP_SESSION":"$XDG_CONFIG_DIRS"
  fi
  export XDG_CONFIG_DIRS

To add my own dirs I’d use something like /etc/X11/Xsession.d/70-local-my-xdg-path

Answered By: Florian Diesch

On my Ubuntu it was stored in ~/.xsessionrc

Answered By: Gerhard Powell