1

When I try to add Firefox installed with Flatpak on Debian 10 to alternatives with the following command, I get an error:

Command:

sudo update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser "/usr/bin/flatpak run org.mozilla.firefox" 50

Error:

update-alternatives: error: alternative path /usr/bin/flatpak run org.mozilla.firefox doesn't exist

How can I successfully input a program installed with Flatpak to alternatives?

tompi
  • 723
  • 1
  • 6
  • 10

2 Answers2

1

As the error message implies, 'update-alternatives' deals with file paths, not with runnable command lines – it needs to be given an actual file that it would place at "/usr/bin/gnome-www-browser". (The alternatives system doesn't even distinguish whether something is a program or not.)

Flatpak provides executable links of every program at /var/lib/flatpak/exports/bin (one per flatpak ID, corresponding to its default branch), so you should be able to use:

update-alternatives --install /usr/bin/gnome-www-browser \
                              gnome-www-browser \
                              /var/lib/flatpak/exports/bin/org.mozilla.firefox

Otherwise write a one-line shell script, put it somewhere in /usr/local, and give that to update-alternatives.

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • This is exactly what I needed. I had the impression that I was looking for something like this, but didn't know that Flatpak offers what I needed by default. Thank you :) – tompi Nov 19 '20 at 12:11
0

In addition to user1686's answer here is a more complete example, but be careful I'm using Flatpaks installed in user space (--user), which may seem contradictory to some, but I use my systems only for myself. Replace it with the path used in user1686's answer if you need to.

# As suggested by user1686
update-alternatives --install \
  /usr/bin/gnome-www-browser \
  gnome-www-browser \
  "$HOME/.local/share/flatpak/app/org.mozilla.firefox/current/active/export/bin/org.mozilla.firefox" \
  1

sudo update-alternatives --config gnome-www-browser

# This may also be required
update-alternatives --install \
  /usr/bin/x-www-browser \
  x-www-browser \
  "$HOME/.local/share/flatpak/app/org.mozilla.firefox/current/active/export/bin/org.mozilla.firefox" \
  1

sudo update-alternatives --config x-www-browser

# This finally got me to use the flatpaked Firefox to use during usage of
# 'aws configure sso' and a few other tools
sudo ln -s \
  "$HOME/.local/share/flatpak/app/org.mozilla.firefox/current/active/export/bin/org.mozilla.firefox" 
  "/usr/local/bin/firefox"

I am aware that the last command is comparable to the nuclear option and make everything else almost pointless. But let's try to play along here while I have not enough to to do further research on things like this: https://docs.python.org/3/library/webbrowser.html

LiveWireBT
  • 904
  • 2
  • 7
  • 34