Customizing Flatpak Desktop Files

Has anyone figured out how to customize a .desktop file for a flatpak app? I want to change the GTK theme for a single app which can be done by setting the GTK_THEME env variable when launching the app.

So I tried to copy the desktop from /var/lib/flatpak/exports/share/applications/org.gnome.Podcasts.desktop to ~/.local/share/applications/org.gnome.Podcasts.desktop and then editing it and after that running update-desktop-database but it doesn’t work. I also tried rebooting and it doesn’t work. And I tried to edit the original file as well.

It appears that those desktop files aren’t used when launching the app from the home screen but I can’t figure out what is file/config is used. According to this https://github.com/flatpak/flatpak/issues/1286 you should be able to put the desktop files in ~./local/share/applications and have it work.

Also for me the XDG_DATA_DIRS variable is not set, so I tried to set it but I wouldn’t recommend doing that because that gave me a black screen instead of a login screen. Luckily I was able to ssh to the phone and remove it.

All the Flatpaks I have installed seem to follow this scheme:

.desktop files stored on a per-app basis at ~/.local/share/flatpak/app/<example.flatpak.name>/current/active/export/share/applications/

Then a directory of symlinks to each individual .desktop file at ~/.local/share/flatpak/exports/share/applications/.

E.g.

$ ls -l ~/.local/share/flatpak/exports/share/applications/
example.flatpak.one.desktop -> ../../../app/example.flatpak.one/current/active/export/share/applications/example.flatpak.one.desktop
example.flatpak.two.desktop -> ../../../app/example.flatpak.two/current/active/export/share/applications/example.flatpak.two.desktop

Interesting. That’s not how it is on my system:

purism@pureos /
0 % fd -I -H org.gnome.Podcasts.desktop
var/lib/flatpak/app/org.gnome.Podcasts/aarch64/stable/c55e23f7977939f898a8194bf6d06257ac207d36e894f7b7ee889b1e3f289671/files/share/applications/org.gnome.Podcasts.desktop
var/lib/flatpak/app/org.gnome.Podcasts/aarch64/stable/c55e23f7977939f898a8194bf6d06257ac207d36e894f7b7ee889b1e3f289671/export/share/applications/org.gnome.Podcasts.desktop
var/lib/flatpak/exports/share/applications/org.gnome.Podcasts.desktop
home/purism/.local/share/applications/org.gnome.Podcasts.desktop
home/purism/.local/share/flatpak/exports/share/org.gnome.Podcasts.desktop

I have edited all those desktop files so the Exec line is env GTK_THEME=Adwaita:light /usr/bin/flatpak run --branch=stable --arch=aarch64 --command=gnome-podcasts org.gnome.Podcasts but I still get the dark theme (I have the dark theme enabled globally). Running the above line directly from the terminal works. And I have rebooted and run update-desktop-database.

I’m not sure what is wrong but it seems like the .desktop files aren’t used by the launcher (are they parsed once at install and then ignored or something?)

Ah, right, I install all my Flatpaks with the --user flag, so they get installed under my home directory. But the default I think is for system installation, which is where the /var directory comes in.

That said, if you’ve tried editing all the ones you see, then I am not sure. GNOME does seem to do a whole bunch of stuff internally in ways that aren’t always very transparent, and I don’t know enough to say whether there might be some cached value or other sort of override that is happening and causing your modifications to be ignored.