Setting the default browser in Linux

Setting the default web browser in Linux should be easy, and often is. But every once in a while one or another application stubbornly uses a browser other than your preference, and tracking the problem down can a challenge.

How it’s supposed to work

Your desktop environment (DE) should provide a handy setting for this. For example, in Xfce simply open Settings Manager – Default Applications, and there you can set not only your preferred web browser but other applications as well. At this point all should be well and things should just work. Ah, if only it were so easy.

What happens when things go wrong

What happens behind the scenes is that your DE’s configuration manager has set your default browser for you. This would work great if there were only one way to set your default browser. In fact there are different ways to set it. When the way your DE set it isn’t the way that an application consults, then you have the annoying experience of that application appearing to not respect your preference.

The solution

What you have to do is find out which things the offending application checks to determine your default browser. The easiest way to do that is to consult the documentation or ask the developers. Then update or remove things as needed.

For example, Quod Libet was ignoring my default browser and using Firefox. The Quod Libet development group informed me that to select the browser to use, Quod Libet tries (in order) gnome-open, xdg-open, sensible-browser, and $BROWSER. I was surprised to discover gnome-open installed on my system, despite Gnome itself not being installed, and that it was pointing to Firefox. So that was the culprit. Uninstalling libgnome2, which provided the unwanted gnome-open, not only resolved my problem but also cleaned up some Gnome cruft that didn’t belong on the box anyway.

If you can’t determine which things the offending application checks, then you will need to check all the different ways that your system has to set the default browser. When you find one that doesn’t match what you want, update it. Then see if the application now uses your preferred browser. Repeat as needed until the offending application behaves.

That sounds easy enough, but as far as I know there is no comprehensive list of all the ways that an application might consult in order to select the browser to use. What follows are the different ways that I have encountered, though I am sure this is an incomplete list.

xdg-settings default-web-browser; xdg-open

This is what I most commonly see used. When in Xfce’s Default Applications I set the default browser to, for example, Brave Web Browser, what happens behind the scenes is that Xfce gives the command xdg-settings set default-web-browser brave-browser.desktop

To confirm that xdg-settings default-web-browser is set as you wish, give the command xdg-settings get default-web-browser and it will respond with (following the example above) brave-browser.desktop . If it doesn’t respond with the the .desktop file of the browser you want, then use the command in the previous paragraph to set it as desired.

xdg-mime x-scheme-handler/http(s)

Some applications don’t look at your default web browser and instead consult what application is set to open HTTP or HTTPS. MIME tells the system which application to use when opening what things.

When Evolution, and Thunderbird‘s calendar (though oddly not Thunderbird’s mail client) ware ignoring my preference for Brave Browser, I ran these two commands to see what is associated with HTTP and HTTPS:

warren@optiplex:~> xdg-mime query default x-scheme-handler/http
firefox.desktop
warren@optiplex:~> xdg-mime query default x-scheme-handler/https
firefox.desktop

There’s the problem. This command set things right (all on one line):

xdg-mime default brave-browser.desktop x-scheme-handler/http x-scheme-handler/https

gnome-open

I know this is a thing because Quod Libet’s developers told me they consult it. However I’m not a Gnome user and I don’t know anything else about it.

sensible-browser

This is another thing that I only know about because Quod Libet consults it, but I don’t know anything else about it.

$BROWSER

To see if this envar is defined on your system, give the command echo $BROWSER . On my boxes it is not defined, so what comes back is an empty line. If it is defined to something you don’t like, you can delete or redefine it as you would any other envar.

About Warren Post

So far: Quality Assurance crash test dummy, jungle guide, tech support monkey, entrepreneur, IT consultant, teacher, beach bum, diplomat, over-enthusiastic cyclist.
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a comment