The .desktop
file for each app is installed inside its checked out tree.
So if you install org.gnome.Builder
system-wide, the desktop file is at:
/var/lib/flatpak/app/org.gnome.Builder/current/active/files/share/applications/org.gnome.Builder.desktop
However Flatpak knows a few things about desktop apps in general. One thing it knows is that an app will always have a .desktop
file in its tree under share/applications/${APPID}.desktop
, so it actively searches for these and “exports” them.
That means you can find the .desktop
file in the exports/
directory for the app, which in the previous example is:
/var/lib/flatpak/app/org.gnome.Builder/current/active/export/share/applications/org.gnome.Builder.desktop
But then that’s not very useful, Flatpak can’t tell your desktop to go and search for apps in all the possible exports/
directories, one for each installed app.
So in addition, Flatpak takes everything for the per-app exports/
directories and puts it in a global exports/
directory. That means for our example you can find it at:
/var/lib/flatpak/exports/share/applications/org.gnome.Builder.desktop
All the above applies to per-user applications as well, just replace /var/lib/flatpak/
by ~/.local/share/flatpak/
Now, how does your desktop find those desktop files? It looks under each of the directories mentioned in the $XDG_DATA_DIRS
variable. On my system:
$ echo $XDG_DATA_DIRS
/home/mathieu/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/
And it looks into them in order, and stops at the first it finds. So when your desktop finds /var/lib/flatpak/exports/share/applications/org.gnome.Builder.desktop
, it won’t go and read the /usr/share/applications/org.gnome.Builder.desktop
file you created, because that has a lower priority. (it comes later in $XDG_DATA_DIRS
)
One path that isn’t present in $XDG_DATA_DIRS
but should always have precedence over the others is ~/.local/share/applications/
. Try adding your custom desktop
file there, and make sure it’s named exactly like the one from the app you’re trying to override.
(This post derived from this github comment with permission, please feel free to edit and update this post!)