Where are all the installed .desktop files located for each application?

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:


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:


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:


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:


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!)

1 Like

Nice write-up. One note: the GitHub comment link is broken and just points back to this post :slight_smile:

1 Like

I wrote the original github comment here: Where are all the installed flatpak apps .desktop files located · Issue #1286 · flatpak/flatpak · GitHub

And I did give my permission for castrojo to reuse it when he asked me over personal email.

I can’t figure out how to edit the post though, so if someone can, feel free to change the link above so it points to the right place :slight_smile:

1 Like