Qball's Weblog

Gnome 3 and setting custom XDG_DATA_DIRS

Tags General 

I installed gnome3 from the gnome3-team ppa (or how it was called) and this seems to solve a lot of the issues I have been experiencing (most important the complete X crash).

But then I wanted to add a custom path to the XDG_DATA_DIRS. I have my own written software installed in /opt/mpd/ that I own as my own user. This way I can update install it etc, all as my user, without needing root permission. It also keeps things clean and separated.

So I wanted to add /opt/mpd/share/ to XDG_DATA_DIRS.

First attempt was to edit /etc/environment and add it there, that completely broke lightdm and caused upstart to loop start lightdm/X. (resulting in my computer being unusable and had to go into recovery mode to fix.).

I _wonder_ why the hell they do it this way? in the old day after N failures, you would get a message, or it would not try to restart.  So if any upstart guy is reading this, please please please do fix!.

So wondering where XDG_DATA_DIRS was set I found: /etc/X11/Xsession.d/60×11-common_xdg_path and /etc/X11/Xsession.d/55gnome-session_gnomerc. I do not realy want to edit these, but in the gnome-session_gnomerc one I found that in sourced ~/.gnomerc.

However adding just a simplew export XDG_DATA_DIRS=$XDG_DATA_DIRS:/opt/mpd/share/  does not work, because then the default path /usr/share/ is no longer added to the list…. (why????)

So doing the following fixed it for me:

DEFAULT_XDG_DATA_DIRS='/usr/local/share/:/usr/share/'

if [ -z "$XDG_DATA_DIRS" ]; then
    export XDG_DATA_DIRS="$DEFAULT_XDG_DATA_DIRS":/opt/mpd/share/
else
    export XDG_DATA_DIRS="$XDG_DATA_DIRS":/opt/mpd/share/
fi

Do make sure that /opt/mpd/bin is in your path.