26

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
  • 7
    +1 for the “I don't regard chrome as high as they do themselves” ;-) – mirabilos May 8 '15 at 13:13
27

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
  • 2
    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 1 '15 at 12:07
  • @Tino: argument it. – Marco Sulla May 12 '16 at 22:12
  • 3
    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 7:04
  • @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 6: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 9:04
4

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
  • 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 8 '15 at 10:17
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.

  • Could you specify how your answer differs from the accepted one? – Marc Vanhoomissen Oct 16 '17 at 14:16
  • 1
    Are you trying to ask why you had to use the full path for qutebrowser? – Charles Green Oct 16 '17 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.