9

I recently installed Lubuntu 19.04 (LXQt) and I want to change the default browser from Firefox to Google Chrome. However, even though I set Chrome as the default browser in the settings, Firefox still remains the default whenever I try to open html files from my computer (or click on any links).

I'm not sure why the OS is not listening to my instructions. I've set chrome as the default browser in both the "Session Settings" menu, and the "update-alternatives." I've even changed it manually in /usr/share/applications/defaults.list, and it still won't change. No matter what I do, Firefox remains the default browser.

Any idea what's going on ?

PS: I know I could probably solve the problem by removing Firefox, but I don't want to do that. I want to keep both browsers installed, just have Chrome be the default.

7
  • Check the file $HOME/.config/mimeapps.list. Sep 20, 2019 at 2:36
  • That file does not exist.
    – johnymm
    Sep 20, 2019 at 2:37
  • Other than logging off and back on, I'm not sure what else to try. Maybe an uninstall of Firefox, confirm that Chrome is the default, then reinstall of Firefox would help. Sep 20, 2019 at 2:39
  • Thanks. I've rebooted many times and Firefox seems to remain the default. I've also tried uninstall/reinstall, and Firefox becomes the default as soon as it's installed. I'm not sure what's going on, lol.
    – johnymm
    Sep 20, 2019 at 2:41
  • I was writing an answer using the Lubuntu manual (manual.lubuntu.me/3/3.2/3.2.17/alternative_configurator.html) but i've had an issue on my 19.10 system so I'm chasing that down sorry.
    – guiverc
    Sep 20, 2019 at 2:44

2 Answers 2

15

Ideally you'd just follow the manual, ie.

https://manual.lubuntu.me/3/3.2/3.2.17/alternative_configurator.html

however it doesn't work for browser due to a known issue (Task 53 for the Lubuntu Team).

On the bug https://bugs.launchpad.net/ubuntu/+source/lxqt-session/+bug/1824654 there is a workaround, which is :-

WORKAROUND

  1. Remove $BROWSER from the /etc/xdg/xdg-Lubuntu/lxqt/session.conf
  2. Remove $BROWSER from the $HOME/.config/lxqt/session.conf
  3. Get rid of the environment variable with unset BROWSER
  4. Follow these rules for switching browsers:
    • Do NOT use $BROWSER, which can be set as a "Default Application" or an "Environment Variable" in lxqt-config-session ("Session Settings")
    • To switch between chromium, firefox, or opera as default browsers, you can use the in-application mechanism
    • For browsers without an in-application mechanism:
      1. Find the desktop file in /usr/share/applications associated with the browser, e.g. chromium-browser.desktop
      2. Run xdg-settings set default-web-browser browser.desktop

Please note I've just copy/pasted the work around from the 1824654 bug report. The T53 task can be found at https://phab.lubuntu.me/T53 though it may require login permissions

All information here was provided by @wxl

4
  • 2
    Thanks for the answer. With LXQt installed on Ubuntu 20.04 server, the conf from step 1 was located in /etc/xdg/lxqt/session.conf.
    – SaTa
    Sep 28, 2020 at 12:39
  • I have lxqt on Lubuntu 20.04 and this also works.I changed the gui session application to chromium and it made a change in step 2 (session.conf). Does it suffice? CAn I leave browser in step 2 with chromium?
    – Timo
    Mar 9, 2021 at 19:48
  • what is the in-application mechanism?
    – Timo
    Mar 9, 2021 at 19:51
  • xdg-mime query default text/html gets firefox.desktop after the 4 steps. I do npm start in a react dir and .. it works now! It starts midori, maybe because I changed sudo update-alternatives --config x-www-browser to midori.
    – Timo
    Mar 9, 2021 at 19:52
0

The accepted answer resolves the issue of Lubuntu's dubious use of the BROWSER environment variable, but that's just one finger in a dike with a whole lot of holes. Setting a default browser in Linux is like playing Whack-a-Mole, you fix something that works in one app, some other application has another way that's still broken.

It's almost understandable that Lubuntu did it that way, the environment variable pre-empts most (but not all) ways of launching a browser, so that was actually something they could reasonably control; problem was, it was different than the "standard" way to do it, they didn't (as far as I can tell) document a way to change it, and frankly environment variables ought to belong to the user.

So. XDG utilities are FUBAR IMO, and, once you've followed the advice in the approved answer, you are likely to still have some cases were some program or app opens the wrong browser, thanks to XDG simply not working. For example, after I deleted the BROWSER entries in the lxqt config files, I was able to run xdg-settings set default-web-browser without getting an error; except that it did not actually set the default web browser. Subsequent calls to xdg-settings set default-web-browser continued to return Firefox as the default browser. Though I was able to get x-www-browser and sensible-browser to run my preferred browser, other methods still ran Firefox. Python's webbrowser module continued to open Firefox, for instance.

In the end, I decided scorched earth was the only way. I searched for every instance of "firefox.desktop" in various locations for config files, and replaced it.

find /usr/share /etc ~/.config -not -type d | xargs -d '\n' grep -F firefox.desktop

Once I changed them all, it would finally reliably launch the correct browser. But this won't likely work forever: an upgrade could overwrite some of those files.

And to think I switched to Linux long ago so I wouldn't have to deal with this Windows bull.

You must log in to answer this question.

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