Ubuntu – Force Firefox to use xdg-open to open downloaded files

firefoxkubuntuxdg-open

Firefox in Kubuntu is broken, as it doesn't follow the system default applications that I can configure using "file associations" in the KDE Control Module. For example, it wants to open folders with K4dirstat, videos in itself and PDF files with GIMP.

I want Firefox to download everything (or almost everything) by default, and then when I double click the downloaded file in Firefox I want it do open using xdg-open (or using the application xdg-open would use), including "open the containing folder" thing.

My question is similar to this question from 2011: Firefox: open downloaded files with system default application

But I want "save file" marked in that window, and later open with a sane application from within Firefox.

This unanswered question also seems related, as if it is possible to do what I want. I think that other question is answered too: https://askubuntu.com/questions/546113/change-default-application-for-a-file-type-in-dolphin-and-firefox

Best Answer

I am not sure this is exactly what is asked. I will be posting on how to make Firefox downloads list open a file in a desired application.

Some newly installed applications take over the "default" status in Firefox's about:preferences instead of the per-filetype normal application set at system level (e.g. Palemoon takes over as default instead of gwenview for JPEG files, Inkscape or File Roller takes over instead of Okular for a PDF file.).

"Always ask" is the choice that should be used in this case and then trying to create a per-user file ~/.local/share/applications/mimeinfo.cache with the lines:

[MIME Cache]
application/pdf=okularApplication_pdf.desktop

The disadvantage of the above is that it is a per-file-type setting. To have a solution for all files (as said in this answer), run:

cd .local/share/applications/
ln -s mimeapps.list defaults.list

In case this stops working: see that the undesired application is not again selected under about:preferences: be sure "Always ask" is selected there. Setting manually a different program (even the default for your file-type at system level, but which is not marked as "default" in the list for your file under about:preferences) might not work.


Tested in Firefox 60.0 in Kubuntu 18.04.

Related Question