18

I run Firefox from a Flatpak but I can't find how to have it open links when I click them in various XDG-compliant apps. How can I have xdg-open run Firefox from a Flatpak distribution?

The application itself shows in preferences that it is not the default browser. It offers a button to set itself as default but it seems to have no effect.

3 Answers 3

21

You need to use the xdg-settings command. This should return your current default browser:

xdg-settings get default-web-browser

To change it to your Flatpak version, do this:

xdg-settings set default-web-browser <your_flatpak_browser.desktop>

To validate your new settings, do this:

xdg-settings check default-web-browser <your_flatpak_browser.desktop>
8
  • 5
    I had to scan my whole filesystem to find the .desktop file. It is located in /var/lib/flatpak/exports/share/applications/org.mozilla.firefox.desktop. Commented Oct 16, 2020 at 23:24
  • I should have guessed that, but I moved my flatpaks to $HOME so the locations are totally different and I couldn't remember where the default location was. Commented Oct 16, 2020 at 23:27
  • 4
    The path leading to the directory is somehow already added to the list of directories that XDG will search in, but I had to find the actual name of the file. Then the command xdg-settings set default-web-browser org.mozilla.firefox.desktop managed to install it. Commented Oct 16, 2020 at 23:48
  • OK, good to know. Commented Oct 16, 2020 at 23:48
  • 1
    xdg-settings set default-web-browser com.brave.Browser.desktop WFM Commented May 8, 2023 at 14:30
6

In addition to the above posted:

xdg-settings set default-web-browser <your_flatpak_browser.desktop>

the following settings helped me:

xdg-mime default <your_flatpak_browser.desktop> x-scheme-handler/https x-scheme-handler/http

E.g.:

xdg-mime default org.mozilla.firefox.desktop x-scheme-handler/https x-scheme-handler/http             
xdg-settings set default-web-browser org.mozilla.firefox.desktop
2

For Linux Mint (21.2), the best way to set a flatpak-installed Firefox as the default browser was within Default Applications, Web Browser, then select "Other..." and enter

flatpak run org.mozilla.firefox "%s"
1
  • Perfect. This works on Ubuntu 24.04. Commented Jan 7 at 9:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.