Firefox – Where Does It Get Default Applications for Opening Files?

file openingfirefox

By default, the Firefox (33.0) on my FreeBSD 11.0-CURRENT has the default application for opening PDF files set to Inkscape. Firefox does remember my previous choice, evince, in the “What should Firefox do with this file?” dialog, so until recently I was just confused where this configuration came from, but mostly ignored it because it did barely concern me.

I have however recently started using Zotero as my literature database. Zotero runs as a firefox plugin, and ignores the choices made in my Firefox preferences to open PDF files with evince or ask me what to do with them, and just opens them using Inkscape. This made me try to follow up on this particular configuration item of Firefox, but I could not find where that default is set.

I could not find the string Inkscape (or inkscape) in any Firefox-related file in my home directory.

Best Answer

A link to a “similar question” (xdg-open default applications behavior – not obviously related, but some experimentation showed that the behaviour is indeed equivalent to the one of xdg-open) led me deeper down the rabbit hole. While Firefox does not rely on, or inherit rules from, xdg-open, it uses the MIME specification files just as xdg-open does.

On a user basis, the MIME opening behaviour is configured by the specification file ~/.local/share/applications/mimeapps.list.

For me, this file contains just a few reasonable protocols and HTML (and similar) files connected to userapp-Firefox-??????.desktop, but you could easily add a line like

application/pdf=evince.desktop

to solve that problem on a per-user basis. If the file does not exist yet, make sure to add a section header, such as

[Default Applications]
application/pdf=evince.desktop

Deeper down, the mime types are defined in /usr/local/share/applications/mimeinfo.cache (this may be /usr/share/… if you are not on a FreeBSD system), which does list application/pdf=inkscape.desktop;evince.desktop;. Both evince.desktop and inkscape.desktop in that folder contain MimeType=[…]application/pdf;[…].

The mimeinfo.cache is automatically generated from the mime types listed in the .desktop files without any well-defined order, so you will have to either remove the PDF mime type from Inkscape and regenerate the cache using update-mime-database, or generate a mimeapps.list (either globally in /usr/local/share/applications/, or for your user in ~/.local/share/applications/mimeapps.list).

Related Question