TROMjaro Forum

Setting Flatpak apps to follow system theme

Set Flatpak apps to follow system theme by running the following command:

flatpak override --user --env=GTK_THEME=$("gsettings get org.gnome.desktop.interface gtk-theme")

Full details as follows:

Previously I used Flatseal to set a theming environment variable, i.e.:
Flatseal > All Applications > Environment > Variables > Add a new Variable

…and for some reason in the recent testing I did I originally mentioned putting in GTK_THEME=Adwaita-dark here, which seems a bit silly in retrospect (I have since updated the results and details in that thread). I must be still a bit brain damaged to have forgotten that I had already changed this on my main system to be set to my system theme, e.g. GTK_THEME=Skeuos-Grey-Dark

So to make it sync, we just need to replace the theme name with a variable, and it turns out you can retrieve the current theme name on your system with:

gsettings get org.gnome.desktop.interface gtk-theme

I couldn’t find any syntax that works in Flatseal to set this, and I suspect there might be an issue with the way it reads in commands that makes it impossible, but we can test and work out the correct syntax using the flatpak run command. E.g. if we wish to launch Flatseal with the system theme, the following will do the trick:
flatpak run --env=GTK_THEME=$("gsettings get org.gnome.desktop.interface gtk-theme") com.github.tchx84.Flatseal

To make any app always run with the system theme, as a replacement for the Flatseal method, we can instead use the flatpak override command as follows (if you leave out “–user” it will set it globally for all users and you will need to use sudo):
flatpak override --user --env=GTK_THEME=$("gsettings get org.gnome.desktop.interface gtk-theme") com.github.tchx84.Flatseal

If you find it a bit confusing that I am using Flatseal as the example app to modify, then click here.

You can run run the above commands for any application. For example, if you wanted to do this with gmusicbrowser, first find the webpage for it on Flathub, then click on the little down pointing arrow beside “Install”. Here we can find the needed flatpak run command for it: org.gmusicbrowser.gmusicbrowser which we can now use in both of the above two examples as a replacement for com.github.tchx84.Flatseal

It doesn’t mention it in the documentation, but it turns out that you can simply leave out the app name from this command, and it will set it globally for all Flatpak apps. So our final command then simplifies to:
flatpak override --user --env=GTK_THEME=$("gsettings get org.gnome.desktop.interface gtk-theme")

And yes, it does return a zsh: command not found error, but it works all the same :slight_smile:


You can undo any flatpak override commands using --unset-env=VAR. So for example, I had previously set ADW_DEBUG_COLOR_SCHEME=prefer-dark in the same manner, which meant that some apps were still respecting that preference even when the system theme was set to light. So to undo that I had to run:
flatpak override --user --unset-env=ADW_DEBUG_COLOR_SCHEME

Note that we only need the variable name here, without any value after it.

Also, I found that the flatpak override command does not override any variables that you already have setup for individual apps in Flatseal. E.g. If I had previously set GTK_THEME=Skeuos-Grey-Dark for the Flatseal application itself, I needed to delete that setting from Flatseal, and then run the flatpak override command again for the global setting, and then restart Flatseal for it to work.

In general, many Flatpak apps will follow the system theme change instantly now, while others do require a restart first. Some will only follow the highlight colour, and some will only follow that in the header bar, and some that use their own theming will still not follow it at all. But in general it is a big improvement :slight_smile:

Just to mention this now TROMjaro fixes all of these automatically via the tromjaro-fixes package. We sync the themes across flatpaks that use gtk and also gtk plus libadwaita.

1 Like