<< Back to Table of Contents
Flatpaks are extremely useful in many regards, but they take a fair bit of work to integrate properly into window manager environments. I decided to write a little guide to hopefully help other people trying to get them to work right on their desktops!
D-Bus
If there isn't a D-Bus session running on the host, most Flatpaks will refuse to open. This can be resolved by going in your .xinitrc
and using dbus-launch
to launch your window manager session. Here's what that looks like for me:
exec dbus-launch --exit-with-x11 bspwm
The --exit-with-x11
bit, in essence, ensures that the D-Bus session ends when the X session does.
Launching Flatpak programs
Ensure that your program launcher supports desktop files; for instance, dmenu
doesn't support them by default, but I think there are ways to supplement that functionality.
There's also rofi
, which has this functionality built in when running it using the drun
mode, which is what I use!
An addendum
A friend told me that you can add /var/lib/flatpak/exports/bin
and $HOME/.local/share/flatpak/exports/bin
to your $PATH
, which allows you to launch Flatpaks from the terminal by just typing the name of the Flatpak without needing to type flatpak run
. I haven't been able to try this for myself yet, but this might also expose Flatpaks to dmenu
without the need for an external script or program!
Making Flatpaks use your system GTK theme and font
At this point, you'll most likely notice that Flatpaks look really out-of-place on your system, particularly if you're not using Adwaita as your system GTK theme.
The official Flatpak documentation states that Flatpak reads the GTK-theme
D-Conf key to determine your system's current GTK theme, but this depends on you having the GNOME XSettings daemon (gsd-xsettings
) up and running on your system; ergo, just doing a global filesystem override to your themes directory won't actually do anything unless you're on a desktop environment or you have this manually set up on your own desktop :-(
1. Setting up the GNOME XSettings daemon
On Debian or Debian-based distributions, this is provided by the gnome-settings-daemon
package and gsd-xsettings
can be found at /usr/libexec/gsd-xsettings
; there might be a better way of doing this, but I launch it from my .xinitrc
with this line:
/usr/lib/gsd-xsettings &
2. Installing your host GTK theme as a Flatpak
Next, you can install your host GTK theme as a Flatpak using pakitheme (huge shoutout to refi64 for making this!)
If you aren't running a Polkit authentication agent, you'll need to edit the script and remove -y
from the final Flatpak command.
3. Specifying your system GTK theme and font flags in D-Conf
You'll also have noticed by now that all of your non-Flatpak GTK applications are also using Adwaita; this is because your system is now using gsd-xsettings
to manage your GTK themes. This means that things like lxappearance
won't work anymore, instead you'll be using D-Conf to manage your GTK themes and system fonts. You can set your GTK theme either by using the D-Conf editor or by running the following:
gsettings set org.gnome.desktop.interface GTK-theme [your GTK theme here]
And you can set your fonts with the font-name
, document-font-name
, and monospace-font-name
keys in the same directory. At this point, your Flatpaks should be using your system GTK theme and fonts!
This method is actually really neat because it auto-reloads your GTK theme and is scriptable; you can set an alias in your shell to change your GTK theme, stick it in your sxhkdrc
and make keybinds to easily change between light and dark GTK themes, or do whatever else comes to mind!