How To Get Flatpak Apps To Use The Correct Gtk Theme

Flatpak is a utility for software deployment, package management, and application virtualization for Linux desktops. Like Snap packages, Flatpak provides a sandbox environment which isolates applications from the rest of the system.

Using Flatpak is useful not only for security, but because many programs are available to download as Flatpak packages. You can check out Flathub to see a list of Flatpak applications that you can install. Flatpak packages may also be offered on a program's downloads page.

For how to set up Flatpak and add the Flathub repository in your Linux distribution, check out this page

Get Flatpak applications to use your current Gtk theme


Flatpak is great for many reasons, but there's one annoyance. Due to sandboxing, Flatpak applications use the default Gnome theme (Adwaita), and not whatever Gtk theme you're currently using.

The fix for this issue is to install your current Gtk theme from Flathub. This way, Flatpak applications will automatically pick up your current system Gtk theme and use that instead of Adwaita.

Here is Font Finder application installed from Flathub. As you can see, I'm using the Adapta Gtk theme but Font Finder does not:

Flatpak app no system theme

And here is Font Finder again, after applying the "fix" mentioned in this post:

Flatpak app using system theme

Requirements:
  • Flatpak 0.8.4+
  • to support theming, Flatpak applications need to use Gnome 3.24+ platform
  • the same theme installed from Flathub needs to be selected in Gnome Tweaks application (the theme needs to have the exact same name)

Not all Gtk themes are available on Flathub so you can't theme Flatpak applications with any Gtk theme out there. To see all the Gtk themes available on Flathub, run this (after setting up Flatpak and adding the Flathub repository):

flatpak remote-ls flathub | grep org.gtk.Gtk3theme

Right now there are about 11 themes with 25 theme variations in Flathub. Here's the list:

$ flatpak remote-ls flathub | grep org.gtk.Gtk3theme
org.gtk.Gtk3theme.Adapta
org.gtk.Gtk3theme.Adapta-Eta
org.gtk.Gtk3theme.Adapta-Nokto
org.gtk.Gtk3theme.Adapta-Nokto-Eta
org.gtk.Gtk3theme.Ambiance
org.gtk.Gtk3theme.Arc
org.gtk.Gtk3theme.Arc-Dark
org.gtk.Gtk3theme.Arc-Dark-solid
org.gtk.Gtk3theme.Arc-Darker
org.gtk.Gtk3theme.Arc-Darker-solid
org.gtk.Gtk3theme.Arc-solid
org.gtk.Gtk3theme.Breeze
org.gtk.Gtk3theme.Breeze-Dark
org.gtk.Gtk3theme.Communitheme
org.gtk.Gtk3theme.Greybird
org.gtk.Gtk3theme.Materia
org.gtk.Gtk3theme.Materia-dark
org.gtk.Gtk3theme.Materia-light
org.gtk.Gtk3theme.Mint-Y
org.gtk.Gtk3theme.Mint-Y-Dark
org.gtk.Gtk3theme.Mint-Y-Darker
org.gtk.Gtk3theme.Numix
org.gtk.Gtk3theme.Pop
org.gtk.Gtk3theme.Pop-light
org.gtk.Gtk3theme.elementary

To install a theme, use this command (again, after adding the Flathub repository!):

flatpak install flathub org.gtk.Gtk3theme.<theme-name>

As an example, here's how to install Ambiance Gtk theme:

flatpak install flathub org.gtk.Gtk3theme.Ambiance

This tweak also works for icon themes, but there are currently only 2 icon themes available on Flathub. You can check this by running:

flatpak remote-ls flathub | grep org.freedesktop.Platform.Icontheme

No comments: