Join us for the next conference in 2027!
Set Linux XDG Default App To A Flatpak

Set Linux XDG Default App To A Flatpak

March 25, 2025

Did you know that Flatpak applications can be accessed and referred to in a Linux command shell using their fully qualified IDs?

As an example, here is how to find the Flatpak app ID for the LibreWolf web brower.

flatpak list | grep librewolf  
# LibreWolf	io.gitlab.librewolf-community	136.0.2-1	stable	system

In this case the Flatpak ID is io.gitlab.librewolf-community.

Flatpak ID as command

which io.gitlab.librewolf-community
# /var/lib/flatpak/exports/bin/io.gitlab.librewolf-community

This is just a script that wraps flatpak run:

cat /var/lib/flatpak/exports/bin/io.gitlab.librewolf-community                                                                                                                                      ✔ 
# #!/bin/sh
# exec /usr/bin/flatpak run --branch=stable --arch=x86_64 io.gitlab.librewolf-community "$@"

Set XDG default to Flatpak app

Flatpak creates a ".desktop" file for apps exported from their environments, and this can be used in xdg-settings defaults.

xdg-settings get default-web-browser 
xdg-settings set default-web-browser io.gitlab.librewolf-community.desktop 
xdg-settings check default-web-browser io.gitlab.librewolf-community.desktop
# yes