2

I've installed some app under /opt/myapp, which has a /opt/myapp/share directory. As I finish installing, it tells me:

Note that '/opt/myapp/share' is not in the search path
set by the XDG_DATA_HOME and XDG_DATA_DIRS
environment variables, so applications may not
be able to find it until you set them. The
directories currently searched are:

- /usr/share/gnome
- /home/joeuser/.local/share/flatpak/exports/share
- /var/lib/flatpak/exports/share
- /usr/local/share
- /usr/share

What's the right way to add directories to that list - system-wide and as a single user?

0

I'm not sure about system wide.. but as a single user (which is accessible sytem-wide) I include this line in my ~/.profile file.

XDG_DATA_DIRS="/var/lib/flatpak/exports/share:$XDG_DATA_DIRS"

And you can adapt that to meet your own needs.

  • My system completely crashed after adding this to my ~/.zprofile (since I use zsh) – Xerus Jul 23 at 11:30
0

The German ubuntuusers wiki has a nice list of files and directories that can be used for that purpose.

Setting it globally

From my research, appending to that environment variable globally is not trivial, but here are some pointers:

  • If you want to overide the existing value, /etc/environment is the easiest way
  • Depending on the system configuration /etc/profile might also be a good way, because you it is executed by the shell
  • Other files to try might be /etc/X11/Xsession.d/* and /etc/security/pam_env.conf

Setting it per-user

  • $HOME/.profile (or $HOME/.zprofile for zsh users) is suggested in multiple places, however adding the line XDG_DATA_DIRS="$HOME/.local/xdg:$XDG_DATA_DIRS" in there rendered my desktop completely non-functional upon login
  • The way that worked for me was to create $HOME/.xsessionrc and put the line export XDG_DATA_DIRS="$HOME/.local/xdg:$XDG_DATA_DIRS" in there. Of course, you have to replace $HOME/.local/xdg by the directory you want to add. Please also note that this will only set the variable for graphical applications, not for the shell (so your value won't be mentioned in echo $XDG_DATA_DIRS), but that should not be a problem.

Recommendation

Just execute this line and log in again, and it should work:

echo export 'XDG_DATA_DIRS="/opt/myapp/share:$XDG_DATA_DIRS"' >> ~/.xsessionrc

If for whatever reason your system is nonfunctional after that, enter Recovery Mode, go into the root shell and type rm /home/<username>/.xsessionrc and then reboot to get back into your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.