One of the reasons why some users avoid installing Flatpak apps is that most Flatpak apps don’t change their appearance as per the current system theme. This makes the applications look out of place in your otherwise beautiful setup.
The official way to apply GTK themes to Flatpak apps is by installing the desired theme as a Flatpak. However, only a few GTK themes can be installed for the job.
If you have found a beautiful GTK theme, your Flatpak applications will still use their default appearance. But wait! There is a workaround.
In this tutorial, I will introduce you to a couple of ways to make Flatpak apps aware of external GTK themes and icons.
- Apply GTK theme and icons to Flatpak through command-line
- Apply GTK theme and icons through GUI with Flatseal
1. Applying GTK Themes and Icons to Flatpak applications (Command-Line Method)
Before we proceed, let’s understand why Flatpak apps have this behavior.
Flatpak apps run inside a ‘container’, so they don’t have access to the host filesystem, network, or physical devices without explicitly setting the appropriate permission, and that is what we are going to do.
As I said earlier, this is a workaround, not a flawless solution. Don’t expect it to automatically change the themes of Flatpak apps when you change the system theme. You can, however, change it for all Flatpak apps in one single command.
Recommended Read: Best GTK Themes for Ubuntu and Other Linux Distro
Let’s see how to achieve that. Please note that this method requires that you are familiar with the Linux command line, and you can find your way around the terminal.
Step 1: Give Flatpak apps access to GTK themes and icons location
GTK themes are located in
/usr/share/icons for all users, and in ~/.themes and ~/.icons for a specific user.
To give all Flatpak packages permission to access ~/.themes and ~/.icons run the following command:
sudo flatpak override --filesystem=$HOME/.themes sudo flatpak override --filesystem=$HOME/.icons
Notice that you can’t give access to /usr/share/themes because, according to Flatpak documentation they are blacklisted.
Alternatively, you can do this on a per-application basis as well. You need to specify the application ID for changing the theme.
sudo flatpak override org.gnome.Calculator --filesystem=$HOME/.themes sudo flatpak override org.gnome.Calculator --filesystem=$HOME/.icons
Step 2: Tell Flatpak apps which theme/icon to use
Giving access to the themes and icons directory is not enough because this directory may contain multiple themes. To tell Flatpak which GTK theme/icon to use, first get the name of the desired item and then apply the following command:
sudo flatpak override --env=GTK_THEME=my-theme sudo flatpak override --env=ICON_THEME=my-icon-theme
As you can see in the screenshot below, a couple of themes and icons are available. Copy and paste the exact theme/icon name in the above command:
Alternatively, for individual applications, run:
sudo flatpak override org.gnome.Calculator --env=GTK_THEME=my-theme sudo flatpak override org.gnome.Calculator --env=ICON_THEME=my-icon-theme
and replace my-theme and my-icon-theme with the folder name of the theme and icon you want to apply (and it must be located in ~/.themes and ~/.icons respectively).
2. Applying GTK Themes and Icons to Flatpak applications with Flatseal (GUI Method)
If you are not comfortable executing commands each time to change themes of Flatpak, Flatseal application can help you. Flatseal allows users to change and review the system resource access of installed Flatpak apps. In short, it is a permission manager for Flatpak applications.
You can install Flatseal in any Linux distribution as a Flatpak:
flatpak install flathub com.github.tchx84.Flatseal
With Flatseal, you can perform the GTK theming of Flatpak apps, in a simplified way. Still, you need to know the name of the environment variables.
Setting Theme and Icons for All Installed Flatpak Applications
Open Flatseal and select the All Applications tab. You need to scroll a bit and can find two sections called Filesystem and Environment.
In the “Filesystem” section, you need to specify the locations the Flatpak applications can access. Since we are in the “All Applications” tab, the permissions will be set for all installed Flatpak applications. In our case, you need to add both
Similarly, in the “Environment” section, you need to add two environment variables, as in the command-line method. So set GTK_THEME and ICON_THEME, as shown in the screenshot (Use your theme/icon name instead).
Once done, restart the apps, to get the effect. Note that, this will set the specified theme and icon to all the Flatpak apps.
Setting Theme and Icon for Individual Applications
Like in the command-line method, in Flatseal, you can also choose to theme Flatpak apps individually. This is achieved by toggling the filesystem and environment variable separately for each app. To do this, instead of the “All Applications” tab, you can select each Application tab in Flatseal and do the same process.
You have to restart the particular app to get the applied effect.
3. Other Flatpak App Theme (Experimental)
Till now, we discussed applying GTK themes to Flatpak apps. There are situations when we would want to deal with Qt-based apps. Applying a theme to Qt apps is trickier than applying it to GTK. So, the below method is just a reference and may not work all the time.
Qt Flatpak Apps in KDE Plasma Environment
KDE Plasma uses the Qt framework. So applying themes to qt-based apps is quite easy in this case. Luckily, the global theme applied through KDE system settings most of the time is applied to Flatpak apps also. But, to make the look complete, we need to add a kvantum theme.
In order to apply the kvantum theme, you need to install a kvantum package from Flathub as shown:
flatpak install org.kde.KStyle.Kvantum
Now, it will prompt for two packages and you may need to install the
org.kde.KStyle.Kvantum 1.0.5 (which worked satisfactorily in my case).
Once done, you may change the theme to your liking through the kvantum manager app. If you don’t know how to change kvantum themes, refer to our KDE theme guide. Once the kvantum theme is changed, you can enter the following command in the terminal:
sudo flatpak override --env=QT_STYLE_OVERRIDE=kvantum --filesystem=xdg-config/Kvantum:ro <name of flatpak app>
This will apply the theme to your particular Qt app. You can do the same thing with Flatseal. First, you need to select the particular Qt app you want to theme from the list.
Now, on the filesystem tab, add
xdg-config/Kvantum:ro and in the environment tab, add
QT_STYLE_OVERRIDE=kvantum as shown in the screenshot below:
Don’t forget to restart the app to get the effect.
Test the theme change by running a Flatpak app
If the application is already running, you’ll have to close and start it again. Remember, if the app is reduced to tray, you need to quit and reopen it. You’ll see that the newly started application uses the theme you specified earlier.
Here is a screenshot of GNOME calculator and GNOME builder (Flatpak version) before the above steps:
And after the above steps (With Orchis GTK theme and Tela icons):
That’s better, right? Now, I could leave you here but it would be appropriate to mention the steps for reverting the changes.
Revert the changes
You can reset the changes by resetting all the overrides at once. Please note that this will reset any previous overrides you had explicitly set.
sudo flatpak override --reset
Alternatively, you can reset permissions at the package level as well:
sudo flatpak override --reset org.example.app
If you have previously overridden the GTK_THEME or filesystem for a specific Flatpak package using “flatpak override” resetting will help you set it again.
With the above command, any themes set through Flatseal will not be reverted.
So, to revert or change themes, you need to delete or modify the environment variable in Flatseal app.
Applying Theme to Qt based Applications
Some set of applications uses Qt framework instead of GTK. Applying theme to Flatpak applications, that base of qt is a bit tricky. More or less it is a trial and error process. Normally, most apps accept the global theme settings if you are in a KDE system.
In order to apply the themes, you will need an additional kvantum package from Flathub.
Normal GTK applications load GTK theme specified by gsettings (usually), you can run the following command to get currently applied GTK themes:
gsettings get org.gnome.desktop.interface gtk-theme
And to set the GTK theme, run:
gsettings set org.gnome.desktop.interface gtk-theme my-theme
To do the above with Flatpak, you have to enter a shell session inside the container of the desired application by running:
flatpak run --command=bash org.gnome.Calculator
And inside this session, run the above command:
gsettings set org.gnome.desktop.interface gtk-theme my-theme
GTK_THEMEenvironment variable, which is supposed to be used for debugging purposes. If you managed to make
gsettingswork, then tell me in the comments.
These methods may not be the most seamless way to change the Flatpak app’s theme. However, it is better than nothing.
I hope this helps you. If you face any issues, please mention them in the comments.