The Default Browser on Linux Debacle

The concept of a default browser on linux is a complete mess. There doesn’t seem to be any central, agreed upon method of defining what the default browser is. First there is the $BROWSER environment variable. This seems like a good idea, it can be set globally, and on a per user basis. On the command line, all you need to do is type $BROWSER http://... and you on your way to the website of your choice. If only it were that easy…

Unfortunately, this isn’t widely adopted. In fact on my Gentoo system it doesn’t seem to have any real effect at all. I set in my ~/.bashrc, export BROWSER=/usr/bin/chromium, and yet in the chromium preferences, it still complains that it isn’t the default browser. I know, it would probably be more seamless if I used another distro, but I feel the upstream maintainers of the applications need to agree on a default browser concept, which would make the choice of distro irrelevant.

So on to choice B, I use KDE so I look in the KDE system-settings. In the “Default Applications” section, there is an options for web browser, looks promising. Once again, foiled by the fact that the setting is not universally used. The value chosen is stored in ~/.kde4/share/config/kdeglobals and only respected by KDE/Qt applications. This does most of the job, but I like most users don’t exclusively use just KDE applications, I choose my applications based on how useful they are, not which widget set they are built with. So pretty much all the Gtk/Gnome/other applications still don’t respect the setting. For example, links in thunderbird always want to open with firefox. I even tried creating a user.js file in my thunderbird profile directory and setting to my choice of browser, no joy. In the “about:config” the settings are there, the application just didn’t seem to care. I am sure I did something wrong, but even if I did, it shouldn’t be so hard. There should be a dirt simple way to set the default browser for all applications for my user and then, if they like, applications can provide some mechanism to override this.

I am sure that Gnome as there own way of setting the default browser, and I think it is likely that it works great for Gnome applications and KDE/Qt applications probably ignore it.

The Debian folks have a nice idea, they leverage the “alternatives” mechanism to provide “x-www-browser” which is (I think) in the end a symlink to the browser of your choice. This is great if everyone agrees to launch the browser with this, but has a minor downside. It only addresses system level preferences, not user level. So while you can hypothetically set the default browser system wide (probably good enough considering how many users are the only user of their systems), if an individual user wants to override this, I’m not sure there is an elegant way to do this. “x-www-browser” just ends up being a less flexible variation of the $BROWSER environment variable.

Also, I’ve looked into xdg-settings, looks promising, from which a lot of people have been working on standardizing with. Let see what happens when I play with it.

$ xdg-settings --list
Known properties:
default-web-browser Default web browser

Ohh, looking good!

$ xdg-settings get default-web-browser
which: no chromium in (/usr/bin/chromium
in (/usr/bin)l-workbench

Crap, what the heck does that mean? Why is “MySQLWorkbench.desktop” mentioned? What is going on? Ok, I’m done with my little panic, I’ll try to fix it:

$ xdg-settings set default-web-browser /usr/bin/chromium
xdg-settings: invalid application name
Try 'xdg-settings --help' for more information.

OK, usage, not as obvious as I thought…

$ xdg-settings --help
xdg-settings - get various settings from the desktop environment


xdg-settings { get | check | set } {property} [value]

xdg-settings { --help | --list | --manual | --version }

Use 'man xdg-settings' or 'xdg-settings --manual' for additional info.

Help… not so helpful. Aha, I figured it out from looking at the manual!

$ xdg-settings set default-web-browser chromium-chromium.desktop

Did it work?

$ xdg-settings get default-web-browser
which: no chromium in (/usr/bin/chromium
in (/usr/bin)l-workbench


Alright, xdg-settings while I nice concept, simply isn’t working. So disappointing.

So I’ve got a lot of options, none of which are 100% effective.

So what’s the ideal solution? It’s hard to say, probably a hybrid of some of these ideas. I think a single binary/script named /usr/bin/www-browser which would look first in user’s home directory for a setting and if not found, look /etc/ for a global setting. And would launch the browser of choice. Why not just get everyone to agree on $BROWSER? Well, unfortunately the different browsers have different command line switches. Have a script/binary gives us the opportunity to normalize how the common ones are accessed (if any). More generally, it would allow the config file to have more advanced options than just specifying the path of the default browser. xdg-settings does look like it is on the right track, but I honestly couldn’t get it to do anything that made sense.

Most importantly the application writers (I’m looking at you KDE and Gnome) need to agree upon whatever method they think is best. I honestly don’t care too much about how it works, as long as it works.

10 thoughts on “The Default Browser on Linux Debacle

  1. Chris

    Fedora 14, Firefox as default browser:
    [chris@localhost ~]$ xdg-settings get default-web-browser
    [chris@localhost ~]$ locate mozilla-firefox.desktop

    I then did these steps which launched firefox:

    It sounds like this is meant to work but doesn’t due to a bug (It opens the .desktop file in your text editor:
    xdg-settings get default-web-browser | locate | xdg-open

    Maybe next version of Ubuntu/Fedora/gnome.

  2. Vladimir

    Problem was more than stupid… Just edit files
    and crop that MimeType line to something like this:

    or just remove x-scheme-handler/http and x-scheme-handler/https

    after that, as root do the following:

    that should do the trick i guess.

    Of course, i removed that MimeType parts only from browser I do not want to be default, I left the .desktop file intact for the to-be-default browser.

  3. Vladimir

    Problem returned after system update… It seams that .desktop file was updated to its default state. Than I found out that problem is not there, but it is in
    “supposed-to-be-default-browser”.desktop I found (also in MimeType line) part that said something like /usr/lib/"not-default-browser"
    removed it and problem is gone(again)

  4. Mike

    Hey there, just happened to run across this page.

    I’m the original author of xdg-settings, and it looks like you’ve found a bug. It’s not supposed to do that. If you are so inclined, I’d be happy to try and figure out why it’s not working for you, so that we can fix it to do what it’s supposed to on systems like yours.

    You can open a bug at or just email me if you’d like.

  5. Evan Teran Post author

    @Mike: I think that part of the issue is that I had build my system with both gnome and kde support (both kde and gnome in my gentoo USE flags).

    This seemed to be a bit a conflict where some programs would look to the gnome system, some would look to kde. Rebuilding my apps with just the kde USE flag made things a lot less confused.

    I’m not sure if I can still reproduce the issue after building it with both USE flags, but if I can, I’ll open a bug.

  6. Pingback: “Default” Applications Obstacle to Desktop Linux Adoption | Ghodmode Development

  7. Zingus

    $BROWSER is well enough and I don’t think it should have structured contents, just the path to a working browser. I see that many years after the last time I looked into that, those guys are still groping in the dark. Linux “desktop integration experts” should all be taken behind the shed and shot.

  8. dired

    Got here after my quest of configuring my default applications once and for all – Thanks for the nice read 🙂

  9. Freddy Vulto

    I think you make a mistake by setting the BROWSER environment variable in .bashrc. You should set it in ~/.profile, because this is the file that definitely gets included by the display manager (e.g. lightdm) – which boots your graphical environment – no matter what is your login-shell setting. See /usr/sbin/lightdm-session (shell script).

    If you have a ~/.bash_profile, make sure to include .profile from there:

    [[ -f ~/.profile ]] && . ~/.profile

    This will set BROWSER via .profile if you login via a text terminal (and your login-shell is set to bash).

    Kubunt-12.04 uses kdm which still includes .bash_profile (see /etc/kde4/kdm/Xsession), but starting from Kubuntu-12.10, lightdm is used as well?

    If you run a program within the graphical environment via ALT-F2, no new shell is started, so .bashrc will not be included at that time either. Only the exports you did in ~/.profile will be active. You can do a “cat /proc/PID/environ | tr 00 12” (fill in PID) to see if a program has the correct BROWSER setting.

    See also:

  10. Chaz

    I managed to get chromium as my default on my plasma desktop by just using

    xdg-settings set default-web-browser chromium-browser.desktop

    Basically when you install chrome, use the .desktop file that’s created in /usr/share/applications/ xdg-settings only accepts the .desktop files as all.

Leave a Reply

Your email address will not be published. Required fields are marked *