34

I'm on 15.04 64 bit Lubuntu and I downloaded chrome from their website, because it can be useful at times, but I want to keep firefox as my default browser and despite having put it as default browser it still doesn't run when I execute x-www-browser. I then manually put firefox as default using the update-alternatives script, but what made me wonder was why chrome put itself at a priority of 200. I don't regard chrome as high as they do themselves, so how would I be able to change the priorities?

This is what I have now and firefox did indeed become my default application, but it shouldn't have, when I clearly put it as default in the firefox interface itself.

  Selection    Path                           Priority   Status
------------------------------------------------------------
  0            /usr/bin/google-chrome-stable   200       auto mode
  1            /usr/bin/chromium-browser       40        manual mode
* 2            /usr/bin/firefox                40        manual mode
  3            /usr/bin/google-chrome-stable   200       manual mode
Peter Raeves
  • 1,099
  • 4
  • 18
  • 33
  • 11
    +1 for the “I don't regard chrome as high as they do themselves” ;-) – mirabilos May 08 '15 at 13:13
  • Here in 2022, the Brave browser is priority 201. They consider themselves one better than Chrome. Browser wars. – Klimaat Mar 18 '22 at 13:07
  • Which means browser package maintainers shouldn't be given a power to set a priority at all. It should be given to the council of distribution maintainers, with the fairly low default. For instance, Debian logical choice would be higher priorities for all open source browsers over any closed source. – Nikita Kipriyanov Aug 24 '22 at 05:34

3 Answers3

34

You can change the priority with:

sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser google-chrome-stable <priority_as_integer>

Example:

before

$ sudo update-alternatives --config x-www-browser 
There are 2 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).

  Selection    Path                         Priority   Status
------------------------------------------------------------
* 0            /usr/bin/google-chrome-beta   150       auto mode
  1            /usr/bin/firefox              150       manual mode
  2            /usr/bin/google-chrome-beta   150       manual mode

after:

$ sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/google-chrome-beta 50
update-alternatives: using /usr/bin/firefox to provide /usr/bin/x-www-browser (x-www-browser) in auto mode

$ sudo update-alternatives --config x-www-browser                                                        
There are 2 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser).

  Selection    Path                         Priority   Status
------------------------------------------------------------
* 0            /usr/bin/firefox              150       auto mode
  1            /usr/bin/firefox              150       manual mode
  2            /usr/bin/google-chrome-beta   50        manual mode
A.B.
  • 89,123
  • 21
  • 245
  • 323
  • 3
    It's not your fault, as your answer is correct, but this "solution" is completely insane. Someone definitively must invent something better than that. – Tino Dec 01 '15 at 12:07
  • @Tino: argument it. – Marco Sulla May 12 '16 at 22:12
  • 5
    Only the most obvious things: 1) `sudo`: so it is per-system but should be per-user or even better per-shell. 2) absolute paths: So it needs a deep insight into the system and just a little typo screws it up, completely. 3) complex and incomprehensible commandline. 4) Unexpected API: Prio 1 usually is top prio. I dont say the numbering is wrong, but please do not call it "Priority". 5) It is a well hidden functionality etc. etc. etc. Such important functionality in Linux/Debian must always be designed with the ordinary people in mind, for those who do not know and do not care. – Tino May 13 '16 at 07:04
  • 1
    @Tino Most "Ordinary People" won't even run into x-www-browser, most GUI apps will respect your DE's file associations and most command line utilities will respect the BROWSER environment variable. – Jonathan Baldwin Aug 31 '16 at 06:33
  • 1
    @JonathanBaldwin Ordinary people neither know about `x-www-browser` nor what `Environment` or `Variable` means. However they **are** affected by `x-www-browser` behind the scenes. Compare with the Volkswagen emissions scandal: Diesel truck drivers are upset as they know, they are affected. But they still do not know anything about AdBlue or how it works. But more importantly: They never want to know and there should be no need for them to know! Ordinary people are no rocket science engineers, and even most rocket science engineers do not need to know about AdBlue in their car as well. – Tino Aug 31 '16 at 09:04
  • @Tino "However they are affected by x-www-browser behind the scenes" By what? Find me an example of an app that "Ordinary people" as you say would use that rely on x-www-browser, file a bug report, and I'll +1 it. Most apps should be using xdg-open. x-www-browser is specific to Debian and it's derivatives anyways. – Jonathan Baldwin Sep 02 '16 at 00:03
  • `s/x-www-browser/update-alternatives/g` – Tino Sep 02 '16 at 14:06
  • Not enough rep to downvote, but this answer appears to be wrong, as the question is asking how to change the priorities, not reinstall with a new priority. @Maythux has the correct answer. – JoshuaCWebDeveloper Aug 20 '22 at 18:37
13

In short: edit /var/lib/dpkg/alternatives/x-www-browser and change priority inside


DETAILS

An easiest and the must answer is to edit the administrative update-alternative files found in the /var/lib/dpkg/alternatives

So edit the x-www-browser file

sudo gedit /var/lib/dpkg/alternatives/x-www-browser

The output will be like this:

auto
/usr/bin/x-www-browser

/usr/bin/firefox
40
/usr/bin/google-chrome-stable
200
/usr/bin/vivaldi-stable
200

Now easily change the priority of chrome (200) by whatever you want then save. (I changed to 50)

check the new settings

update-alternatives --query x-www-browser 
Link: x-www-browser
Status: auto
Best: /usr/bin/vivaldi-stable
Value: /usr/bin/google-chrome-stable

Alternative: /usr/bin/firefox
Priority: 40

Alternative: /usr/bin/google-chrome-stable
Priority: 50

Alternative: /usr/bin/vivaldi-stable
Priority: 200
Maythux
  • 82,867
  • 54
  • 239
  • 271
  • 3
    While this does solve my problem, I find A.B.'s solution much cleaner, as he changes the value through the `update-alternatives` interface. I prefer this way, as you never know what else it does, except for changing the file like you said. Also technically speaking his solution is *easier* as he only uses just 1 command. You use 1 command to open the file, but have to edit and save after that, while `update-alternatives --install` does this for you. – Peter Raeves May 08 '15 at 10:17
  • 3
    This solution still works in Ubuntu 18.04, and seems a lot easier than re-running the install command. Among other things, you can edit more than one priority at a time. – Giles B Aug 19 '20 at 17:27
  • 1
    Still works in 2022 in Debian 11.4. Should be the accepted solution IMO, for the same reasons a stated in the previous comment. – ChennyStar Aug 04 '22 at 06:59
  • Can confirm this is the correct answer for Ubuntu 20.04 – JoshuaCWebDeveloper Aug 20 '22 at 18:38
  • I edited the file manually, and I get now `update-alternatives: error: /var/lib/dpkg/alternatives/x-www-browser corrupt: unexpected end of file while trying to read master file` – Nairum Sep 14 '22 at 21:16
  • WARNING if you edit the file manually: the file must end with two empty lines! – Nairum Sep 14 '22 at 21:21
0

I have qutebrowser installed to ~/.local/bin which is on my $PATH. I had put the full path to the executable, meaning I had to run

sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser $HOME/.local/bin/qutebrowser 200

instead of using qutebrowser only as second-to-last argument (because update-alternatives complained about the path not being absolute) then

update-alternatives --config x-www-browser

EDIT: I'm on debian buster/sid, HTH anyways. EDIT2: Reasoning why I had to specify the full path to qutebrowser.

pylipp
  • 1
  • 2