Set Linux XDG Default App To A Flatpak

The one where we set the default system web browser to LibreWolf installed as a Flatpak

  ·   1 min read

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.

1
2
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 #

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

This is just a script that wraps flatpak run:

1
2
3
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.

1
2
3
4
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