Can't change the xdg-open url-handler to Firefox

7,942

Solution 1

Check the BROWSER variable in /etc/profile and /etc/environment and eventually in your ~/.bashrc. It is probably set to /usr/bin/xdg-open so you should consider to change it to avoid the recursive call.

Solution 2

I had this issue since Chromium made itself the default browser each time I installed it.

Using xdg-mime fixed it:

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

On my Arch Linux system, this added two lines to ~/.config/mimeapps.list, associating HTTP and HTTPS with Firefox.

Now I can have both Firefox and Chromium installed with Firefox being the default browser.

Share:
7,942

Related videos on Youtube

joemaro
Author by

joemaro

Updated on September 18, 2022

Comments

  • joemaro
    joemaro almost 2 years

    My problem is that many programs call xdg-open to open websites but on my Manjaro system (based on Arch Linux) this is somehow bound to cups :)

    When such a call to xdg-open happens, the CPU usage goes up a lot, without anything happens. I restart because the laptop gets hot very quickly.

    ~ $ xdg-settings get default-web-browser
    cups.desktop
    

    When I want to change that, I get the following response:

    ~ $ xdg-settings set default-web-browser firefox.desktop
    xdg-settings: $BROWSER is set and can't be changed with xdg-settings
    

    I can go ahead and change the environment variable for the browser and I'm fixed, BUT only for this one terminal. How could I make this change permanent or add it to autostart?

    I'm using: i3 4.12, fish shell

    • meuh
      meuh almost 8 years
      I don't use a desktop, so don't have the right setup and cannot say what GUI tool does this for you, but there is a file ~/.local/share/applications/preferred-web-browser.desktop on my system that has Exec=firefox %u in it.
    • joemaro
      joemaro almost 8 years
      thanks meuh. my issues arise from programs calling xdg-open though which then calls the connected '.desktop' file, that is connected with the task (=default-web-browser in this case). The .desktop file that gets called is cups.desktop, which i find a bit weird and i'm considering deleting cups, because i don't print anyway :)
  • Mark Deven
    Mark Deven over 4 years
    I have no browser variable in any of those files, is this no longer viable for recent vers?
  • Hendy
    Hendy over 4 years
    My experience: I had BROWSER=firefox in ~/.bashrc but an application still opened URLs in chromium. xdg-settings get default-web-browser produced chromium.desktop, but wouldn't let me set it due to $BROWSER existing. I had to open a new terminal, do export BROWSER="", then run xdg-settings set default-web-browser firefox.desktop and then the application opened urls in firefox. I find that weird, as it's acting like $BROWSER supersedes (and thus won't set), but it wasn't occuring like this in practice. Adding note for anyone else running into this.
  • Alicia
    Alicia over 3 years
    Add text/html as an argument to also handle .html files in the file system.
  • Gustavo Rubio
    Gustavo Rubio over 3 years
    Thanks, this worked for me in Crostini to keep using garcon to open the native browser in ChromeOS but use the chrome binary for running selenium