Fix: Google Chrome is opening Firefox

#desktop, #unix

Google Chrome is my default browser but anytime I download an image it tries to open with Firefox. :/

After some research, I found out that it uses xdg-open to open files. If you type:

$ xdg-open file.png

It will open your default software associated with this type of file. In my case there is nothing and because of that, it tries to open with firefox (I have no idea why).

In order to change it you have to have a file that can open this kind of file, for this example, I will use google-chrome itself to open my .png files.

First, let’s get png filetype:

$ xdg-mime query filetype ~/file.png
image/png

As you can see it is called image/png, to change the default software to open it:

$ xdg-mime default google-chrome.desktop image/png

Yes, you need to associate a .desktop with it, if you don’t know your system’s desktop files look them up at /usr/share/applications.

xdg-mime default will update ~/.config/mimeapps.list if you don’t have xdg-mime (in Arch Linux it comes from xdg-util package) the file looks like:

[Default Applications]
x-scheme-handler/mailto=google-chrome.desktop
text/html=google-chrome.desktop
x-scheme-handler/http=google-chrome.desktop
x-scheme-handler/https=google-chrome.desktop
x-scheme-handler/about=google-chrome.desktop
x-scheme-handler/unknown=google-chrome.desktop
image/png=google-chrome.desktop

[Added Associations]
image/png=geeqie.desktop;xfi.desktop;
video/mp4=vlc.desktop;
application/pdf=google-chrome.desktop;
text/plain=leafpad.desktop;
video/x-matroska=vlc.desktop;
text/markdown=leafpad.desktop;
audio/mpeg=vlc.desktop;
video/x-flv=vlc.desktop;

Line 10 was added when I called xdg-mime default.

References