How to change priorities of x-www-browser?

Solution 1:

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

Solution 2:

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