Flatpak, formerly known as xdg-app, is a utility for software deployment and package management for Linux. It is advertised as offering a sandbox environment in which users can run application software in isolation from the rest of the system.
Note
Parts of this guide assumes that you are using the KDE Plasma desktop environment.
- Flatpak
This details how to install Flatpak and add the Flathub repository so we have access to Flatpak applications.
- Install the
flatpak
package usingyay
.
-
Add the Flathub repository for the user:
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
-
Add the Flathub repository for the system:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
-
To check the Flatpak repos/remotes available in our system:
flatpak remotes --show-details
This details how to use flatpak
to search, install, update, or uninstall Flatpak packages.
Tip
To install or update a package graphically, use the Discover app.
Note
Replace <package>
with the actual name of the package you wish to search, install, or update.
-
To install a package:
flatpak install <package>
Optionally, add the
--user
flag to install the package for the current user only instead of system-wide:flatpak install --user <package>
-
To update a package:
flatpak update <package>
-
To update all packages:
flatpak update
-
To uninstall a package:
flatpak uninstall <package>
-
To uninstall orphaned (unused) packages:
flatpak uninstall --unused
Add the
--delete-data
flag to also delete the app data.
-
To search for a package:
flatpak search <package>
This solves the issue of (some) Flatpak apps not looking native in KDE, and defaulting to a GTK theme instead.
-
Install the Breeze GTK theme (
org.gtk.Gtk3theme.Breeze
) as a Flatpak. -
Override permissions to use the Breeze theme for Flatpak apps.
For system-installed Flatpaks:
sudo flatpak override --system --filesystem=xdg-config/gtk-3.0:ro --filesystem=xdg-config/gtkrc-2.0:ro --filesystem=xdg-config/gtk-4.0:ro --filesystem=xdg-config/gtkrc:ro --env "GTK_THEME=Breeze"
For user-installed Flatpaks:
flatpak override --user --filesystem=xdg-config/gtk-3.0:ro --filesystem=xdg-config/gtkrc-2.0:ro --filesystem=xdg-config/gtk-4.0:ro --filesystem=xdg-config/gtkrc:ro --env "GTK_THEME=Breeze"
This makes Flatpak apps use Dolphin as the system file picker and not any others such as Nautilus (GTK).
This details how to add permission overrides for Flatpaks using Flatseal.
Important
The Flatseal Flatpak app is required for this guide.
-
Launch the Flatseal app. Install the Flatseal (
com.github.tchx84.Flatseal
) app as a Flatpak if you haven't already. -
Choose the Flatpak application you wish to add permission overrides for:
-
To add permission overrides for all Flatpaks (Global), select the All Applications menu item.
-
To add permission overrides for a specific Flatpak, select the specific Flatpak application menu item.
-
-
In the selected Flatpak app's view, several sections of permissions are listed that could be overridden.
These sections include:
-
Share: List of subsystems shared with the host system.
-
Socket: List of well-known sockets available in the sandbox.
-
Device: List of devices available in the sandbox.
-
Allow: List of features available to the application.
-
Filesystem: List of filesystem subsets available to the application.
-
Persistent: List of homedir-relative paths created in the sandbox.
-
Environment: List of variables exported to the application.
-
System Bus: List of well-known names on the system bus.
-
Session Bus: List of well-known names on the session bus.
Most of these sections could easily be updated through simple toggles, some require adding in specific paths or values.
-
-
To expose additional, specific file or directory paths to the application:
-
Under Other files, click the Add folder icon.
-
Add in the path to the file or directory you want to expose to the application in the provided text field.
-
To remove a path, simply click the corresponding cross or X icon next to the path.
-
-
To add in specific environment variables:
-
Under Variables within the Environment section, click the + button.
-
Add in the environment variable (and value) you want to export to the application in the provided text field.
-
To remove an environment variable, simply click the corresponding cross or X icon next to the environment variable.
-
-
After updating the permissions, simply restart the (running) Flatpak app for the changes to apply.
This details how to set global permissions for Flatpak apps and the recommended permissions to set. This should fix issues such as custom cursor icons not being used, and files not being able to be read or written in Flatpak apps to/from a remote directory.
Important
The Flatseal Flatpak app is required for this guide.
-
Refer to the Add Permission Overrides section to set permission overrides for all of your installed Flatpak applications (globally).
-
Under Other files in the Filesystem section, expose the following paths to your Flatpak applications globally:
xdg-videos:rw
xdg-music:rw
xdg-documents:rw
xdg-download:rw
xdg-pictures:rw
xdg-config/fontconfig:ro
~/.icons:ro
/mnt/mynas:rw
[!WARNING]
Replace/mnt/mynas
with the path of your remote directory if you have one, else exclude it.[!TIP]
It is highly recommended to have all user fonts installed to the~/.local/share/fonts
directory so our Flatpak apps can see/use them.[!NOTE]
Thexdg-config/fontconfig:ro
override allows Flatpak apps to utilise the font configurations we have made using the~/.config/fontconfig/fonts.conf
file.
This details how to migrate your configurations and data from standard packages to Flatpaks.
Note
The exact steps to do this for each app might vary, but they are largely the same. This guide will focus on Mozilla Firefox as an example.
Note
This guide assumes that you have been using the standard package of Firefox, and intend to migrate to the Flatpak version without losing your configurations and data.
-
Install Firefox (
org.mozilla.firefox
) as a Flatpak if you haven't already. -
Launch the Firefox Flatpak at least once so that a default (Firefox) profile gets created
-
Identify the folder of your old/existing default Firefox (the standard version) profile in
~/.mozilla/firefox
. The name of the folder should end with.default-release
.List the contents of the
~/.mozilla/firefox
directory:ls -la ~/.mozilla/firefox
Sample output:
drwx------ - myuser 21 Oct 2022 b89131cr.default drwx------ - myuser 23 Nov 20:17 'Crash Reports' drwx------ - myuser 11 Nov 2022 'Pending Pings' drwx------ - myuser 26 Nov 20:02 9h74n8km.dev-edition-default drwx------ - myuser 31 Jan 00:37 30y0vmjh.default-release .rw-r--r-- 128 myuser 1 Nov 2022 installs.ini .rw-r--r-- 416 myuser 1 Nov 2022 profiles.ini
In this example, the folder of the old/existing default Firefox profile is
~/.mozilla/firefox/30y0vmjh.default-release
. -
Identify the folder of your new default Firefox (Flatpak) profile in
~/.var/app/org.mozilla.firefox/.mozilla/firefox
. The name of the folder should end with.default-release
.List the contents of the
~/.var/app/org.mozilla.firefox/.mozilla/firefox
directory:ls -la ~/.var/app/org.mozilla.firefox/.mozilla/firefox
Sample output:
drwx------ - myuser 31 Jan 00:37 . drwxr-xr-x - myuser 31 Jan 00:37 .. drwx------ - myuser 21 Nov 23:25 'Crash Reports' drwx------ - myuser 31 Jan 00:37 7a4wff6q.default drwx------ - myuser 31 Jan 00:37 'Pending Pings' drwx------ - myuser 26 Nov 21:17 l43l38rr.default-release .rw-r--r-- 62 myuser 31 Jan 00:37 installs.ini .rw-r--r-- 259 myuser 31 Jan 00:37 profiles.ini
In this example, the folder of the new default Firefox profile is
~/.var/app/org.mozilla.firefox/.mozilla/firefox/l43l38rr.default-release
. -
Copy the contents of the old/existing (standard) Firefox profile folder (i.e.
30y0vmjh.default-release
), into the new (Flatpak) Firefox profile folder (i.e.l43l38rr.default-release
):[!TIP]
If you have acp
alias forcp -i
, you can override the alias to skip prompts asking to overwrite files by addingcommand
to the beginning of the command below (beforecp
).cp -rf ~/.mozilla/firefox/30y0vmjh.default-release/* ~/.var/app/org.mozilla.firefox/.mozilla/firefox/l43l38rr.default-release