29

I have run update-alternatives as well as the GNOME Preferred apps selection thing. And all point to have the Chromium browser as the default. Yet, when I run xdg-open http://askubuntu.com, Firefox is launched! Similarly, Emacs and Bazaar (bzr) also launch stuff in Firefox instead of Chromium.

Are there any additional settings which affect xdg-open functionality?

Something is definitely broken:

Update

I have purged Firefox:

  • update-alternatives - uses the Chromium browser
  • sensible-browser - opens the Chromium browser
  • xdg-open & gnome-open - opens using google-chrome which kindly tells me "it's not default browser"

!!!!

1

5 Answers 5

14

All of the above answers are basically correct, depending on what you're doing and how the programs you're using are invoking things. For me the problem was that my terminal emulator (Tilix) was still opening the wrong browser (Firefox instead of Chrome), as well as xdg-open foobar.html also opened the wrong browser.

Eventually I figured out that there's also xdg-mime:

xdg-mime query default x-scheme-handler/http
firefox.desktop
xdg-mime query default x-scheme-handler/https
firefox.desktop

That is not correct, so I changed those to:

xdg-mime default google-chrome.desktop 'x-scheme-handler/http'
xdg-mime default google-chrome.desktop 'x-scheme-handler/https'

Then there's also bindings for 'text/html', which I also changed:

xdg-mime default google-chrome.desktop 'text/html'

This, in combination with making sure that the following are also set correctly:

  • the BROWSER environment variable
  • sensible-browser (/usr/bin/sensible-browser, a wrapper script that tries to launch some of the other items in this list)
  • gnome-www-browser (/usr/bin/gnome-www-browser, a symlink to /etc/alternatives/gnome-www-browser)
  • x-www-browser (/usr/bin/x-www-browser, a symlink to /etc/alternatives/x-www-browser
  • www-browser (/usr/bin/www-browser, a symlink to /etc/alternatives/www-browser)
  • all of the "alternative" entries (see update-alternatives --get-selections for a list) that point to a browser.
  • The GConf database (See @Isaiah's answer)

This finally opens the correct browser for most situations on my desktop. 2018 is surely the year of Linux on the desktop.

3
  • 1
    The xdg-mime commands are exactly what I needed! I'm running Manjaro-i3, so I don't have a desktop environment at all. (and the GConf and update-alternatives answers above don't apply) Aug 13, 2019 at 15:38
  • Thank you so much! I was going crazy with Tilix opening Firefox
    – theY4Kman
    Mar 7, 2020 at 20:33
  • XFCE: exo-preferred-applications is the tool to set options for exo-open which is in turn used by xdg-open... so that can screw it up as well.
    – poleguy
    Jun 21, 2023 at 17:58
6

Chromium also has an option in its preferences to make it the default browser:

alt text

That should work, but it if doesn't, read on:

There are several keys in the GConf database that determine what browser is launched by xdg-open:

  • /desktop/gnome/url-handlers/unknown/command
  • /desktop/gnome/url-handlers/http/command
  • /desktop/gnome/url-handlers/https/command
  • /desktop/gnome/url-handlers/about/command

Make sure they are all set correctly:

  • Hit Alt+F2
  • Enter gconf-editor
  • Navigate to the above keys, they should be set to /usr/bin/chromium-browser %s.

alt text

1
  • This is better. I have removed firefox package and guess what? $ xdg-mime query default text/html firefox.desktop
    – Dima
    Dec 21, 2010 at 19:52
5

In my situation I installed Chromium and made it default. Before that Chrome was default browser.

I tried all I was able to do: setting Chromium default browser, changing gconf settings to run Chromium with %U variable (https://askubuntu.com/a/41085/94263), changing alternatives to use Chromium as default x-www-browser (https://askubuntu.com/a/24052/94263), but nothing helped, xdg-open opened new Chromium window with start-page ang couldn't open given link, sensible-browser opened Chrome. I tried to purge Chrome (Chromium was automatically set as default and auto in update-alternatives) and install it again, because I need Pepper flash from there, and it became default x-www-browser alternative again, and again was open with sensible-browser command. Then I've googled some pages and drew my attention on priority and also discovered that there is gnome-www-browser symlink in /etc/alternatives/ too and google-chrome was default there. Chrome had priority set in 200 and Chromium - 40. Google Chrome's priority is higher, so update-alternatives utility installs it as default web-browser automatically as "better version".

I've removed both Chrome and Chromium from x-www-browser and gnome-www-browser:

sudo update-alternatives --remove x-www-browser /usr/bin/google-chrome
sudo update-alternatives --remove x-www-browser /usr/bin/chromium-browser
sudo update-alternatives --remove gnome-www-browser /usr/bin/google-chrome
sudo update-alternatives --remove gnome-www-browser /usr/bin/chromium-browser

Then I've installed new alternatives with other priorities:

sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/google-chrome 40
sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /usr/bin/chromium-browser 200
sudo update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /usr/bin/google-chrome 40
sudo update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser /usr/bin/chromium-browser 200

I don't know are '40' and '200' default priorities for all computers or you will have other numbers. It's better to look before by entering

sudo update-alternatives --display x-www-browser
sudo update-alternatives --display gnome-www-browser

Upd. I've tried to do the same things on completely different system, and priorities were the same as here.

Upd2. If you'll run google-chrome just once, it will change it's priority back to 200 but chromium-browser will stay as default.

This worked for me. Chromium was set up as default automatically and sensible-browser is launching Chromium. But still xdg-open is opening new blank window.

0
1

sensible-browser is the command to launch default web browser from the terminal.

2
  • Sure. But I have no clue what $bzr lp-open is using behind my back. But whatever it uses, firefox gets selected. I think it is using xdg-open which also is selecting firefox.
    – Dima
    Dec 21, 2010 at 19:24
  • After using DoR fixes, chromium is now opened by sensible-browser.
    – Dima
    Dec 21, 2010 at 19:54
0

For me the solution was to run this two commands. Then you only have to select the desired browser from the list.

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

Sources: Launchpad, Bugzilla

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .