Consistent Flatpak Theming in KDE Plasma

I know that I am talking heresy here, I use 2 Flatpaks on my system, Skype and Spotify. Yes, I know that they are in the AUR. Yes, I know proprietary software is evil. There are FOSS blah blah blah..... The Flatpak versions work the best for me. The one thing that I do not like about Flatpaks, is how they ignore my GTK theming preferences that I have set in the Plasma Settings. The official solution from the Flatpak devs, is to install the wanted theme as a Flatpak. I personally think this solution is not ideal. Why have two versions of a theme installed just to fix a limitation inherent in the Flatpak system? Also, what if the theme you are using is not in the Flathub repo? For example, the theme I use for both QT and GTK applications on my KDE Plasma install, is the Dark-openSUSE theme. It is not available in the Flathub repo. It can be found here: Qt Theme and GTK Theme.

Solution #1

After some research, I found a quick and easy fix. The downside is that you need to do it for every Flatpak you have installed.

  1. Copy the following file, ~/.config/gtk-3.0/settings.ini
  2. Create a gtk-3.0 folder in the Flatpak program's install folder. It is located at ~/.var/app/(name of program)/config/
  3. Paste the settings.ini file into the folder you created above.

Solution #2

There is a script that can "automate" the process. It works great. You can find it here, as well as below.

flatheme.sh
#!/usr/bin/env bash

for dir in $HOME/.var/app/*/
do
    confdir="${dir}config/gtk-3.0"
    mkdir -p $confdir
    cp $HOME/.config/gtk-3.0/settings.ini $confdir/settings.ini
done

To use the above script, do the following:

  1. Copy the above text.
  2. Open your favorite text editor.
  3. Paste the text from the above script into your text editor.
  4. Save the above file to your home folder or a folder of your choice. I personally named the file flatheme.sh
  5. Open a terminal window and navigate to where you saved the above script to.
  6. Make your new script executable by typing: chmod a+x flatheme.sh
  7. Run the script by typing ./flatheme.sh

You will only have to do one the above solutions right after installing a Flatpak. Updating the Flatpak will not undo the changes done.

Here are a couple of screenshots showing the results.

Spotify in front of Dolphin.

Dolphin in front of Spotify.

6 Likes