We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

User avatar
chrisy
Posts: 99
Joined: Sat May 25, 2013 7:34 pm

Flatpak, XDG_DATA_DIRS and the desktop menu

Sun May 24, 2020 6:12 pm

I've just installed Flatpak to get a newer version of gpodder. It all works fine, bar the following warning and consequently no icons for installed apps on the menu:

Code: Select all

Note that the directories 

'/var/lib/flatpak/exports/share'
'/home/chris/.local/share/flatpak/exports/share'

are not in the search path set by the XDG_DATA_DIRS environment variable, so
applications installed by Flatpak may not appear on your desktop until the
session is restarted.
OK, fine, I'll add them. Except, I've added them absolutely everywhere I've seen suggested and it still doesn't work!

With reference to this StackExchange post, I've tried ~/.profile, ~/.xsessionrc. I've also tried .bash_profile, which gets rid of the warning in the shell, even though the link from the main answer in that post says not to create this file because it stops .profile being read (.bash_profile removed the warnings whereas .profile didn't so hmm) - this doesn't help with the menu situation however, so I think that's only worked for the interactive shell not my entire user environment.

I even added it to /usr/bin/startlxde-pi, which I really didn't want to do, and even that doesn't work!
flatpak itself adds the entries to run by systemd (systemctl --user show-environment does actually show the correct XDG_DATA_DIRS) and other places.

My XDG_DATA_DIRS is set to:
/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/

There are duplicates in there and it's clearly being overridden by something but I can't figure out what.

I found a blog post from last year with perhaps the same issue, which advises to add the entries manually. There must be a better way!

Any ideas what might be setting XDG_DATA_DIRS very late on login to the desktop?


edit I had a look at the log file in ~/.cache/lxsession/LXDE/run.log, it contains these lines:

Code: Select all

** Message: 12:38:23.003: environement.vala:58: Exporting primary_variable
** Message: 12:38:23.003: environement.vala:59: desktop_environnement XDG_CURRENT_DESKTOP
** Message: 12:38:23.003: environement.vala:150: confir_dirs is null, export : /etc/xdg
** Message: 12:38:23.003: environement.vala:184: Exporting XDG_CONFIG_DIRS
** Message: 12:38:23.003: environement.vala:218: custom_data :/usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:
** Message: 12:38:23.003: environement.vala:219: data_dirs :/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
** Message: 12:38:23.003: environement.vala:220: data_dirs not null, export : /usr/local/share:/usr/share:/usr/share/gdm:/var/lib/menu-xdg:/usr/local/share/:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
** Message: 12:38:23.003: environement.vala:225: Exporting XDG_DATA_DIRS
The code generating this is here. data_dirs is a direct import of XDG_DATA_DIRS in that code, ie. it should be reading the variable that is set in /usr/bin/startlxde-pi immediately before lxsession is executed. But it isn't because the strings are different :?

Hmm, https://valadoc.org/glib-2.0/GLib.Envir ... iable.html states that "The returned string may be overwritten by the next call to get_variable, set_variable or unset_variable.", which may be what is happening here as the strings aren't copied? This could be a bug in lxsession but I can't see how to report it!

User avatar
chrisy
Posts: 99
Joined: Sat May 25, 2013 7:34 pm

Re: Flatpak, XDG_DATA_DIRS and the desktop menu

Mon May 25, 2020 3:11 pm

I found a solution! However it's not great as it requires manually inserting the entire XDG_DATA_DIRS line. I do think that this is a bug in lxsession though and maybe the Raspberry Pi peeps can investigate and fix?

My solution until this is fixed is:
open ~/.config/lxsession/LXDE/desktop.conf in your favourite text editor, and insert:

Code: Select all

[Environment_variable]
XDG_DATA_DIRS=/var/lib/flatpak/exports/share:/home/pi/.local/share/flatpak/exports/share:/usr/local/share/:/usr/share/raspi-ui-overrides:/usr/share/:/usr/share/gdm/:/var/lib/menu-xdg/
Obviously replace the "pi" if you're logged in as a different user,and add anything else you think is relevant - the first two are for Flatpak, /usr/share/raspi-ui-overrides is what startlxde-pi tries to add, and the rest are what lxsession forces upon us.

sw2000
Posts: 1
Joined: Mon Nov 23, 2020 5:51 pm

Re: Flatpak, XDG_DATA_DIRS and the desktop menu

Mon Nov 23, 2020 6:00 pm

chrisy wrote:
Mon May 25, 2020 3:11 pm
I found a solution! However it's not great as it requires manually inserting the entire XDG_DATA_DIRS line. I do think that this is a bug in lxsession though and maybe the Raspberry Pi peeps can investigate and fix?

Obviously replace the "pi" if you're logged in as a different user,and add anything else you think is relevant - the first two are for Flatpak, /usr/share/raspi-ui-overrides is what startlxde-pi tries to add, and the rest are what lxsession forces upon us.
correct.
Debian is talking about this bug here https://bugs.debian.org/cgi-bin/bugrepo ... bug=906288
Ubuntu here: https://bugs.launchpad.net/debian/+sour ... ug/1905289

Flatpak and snap try to add their corresponding search paths for launchers to the users XDG_DATA_DIRS environment variable.
The problem is that debian patched the startlxde script so that paths given early after "login" by either flatpak or snap to search for menu links and icons get overridden when startlxde starts.
Later in your bash/terminal you still get correct contents of XDG_DATA_DIRS but too late for lxpanel to find linked flatpak .desktop files or icons.

User avatar
AkulaMD
Posts: 430
Joined: Fri Jun 19, 2020 6:51 am

Re: Flatpak, XDG_DATA_DIRS and the desktop menu

Tue Dec 22, 2020 9:27 am

chrisy wrote:
Sun May 24, 2020 6:12 pm
I've just installed Flatpak to get a newer version of gpodder. It all works fine, bar the following warning and consequently no icons for installed apps on the menu:

Code: Select all

Note that the directories 

'/var/lib/flatpak/exports/share'
'/home/chris/.local/share/flatpak/exports/share'

are not in the search path set by the XDG_DATA_DIRS environment variable, so
applications installed by Flatpak may not appear on your desktop until the
session is restarted.
Encounter the exact same problem yesterday. Wonder if now they already have a solution for this.
Raspberry Pi OS (64-bit) with desktop and recommended software
Raspberry Pi 5 Model B 4GB at stock speed (never overclock)

Never overclock your Pi.
Encourage optimization instead.

Return to “Raspberry Pi OS”