Firefox: open downloaded files with system default application [duplicate]

When I download a file with firefox, it always asks me with what program I want to open it with, even when that type of file is recognized by the system, and I can double click on it in Nautilus and have it open properly.

This is an example with a deb file, which opens with Ubuntu Software center (as it should) when I double click on it in Nautilus.

enter image description here

I do not want to look for the required program in /usr/bin or whatever in the Firefox dialog, I want Firefox to recognize my system preferences. What I resort to doing now is choose "Download", open Nautilus and double click on the file...

Why can't Firefox recognize my system settings, and how do I get it to?

Thanks!


Solution 1:

Use /usr/bin/xdg-open (it's part of xdg-utils package) to open all the files.

Solution 2:

I can provide some perspective on why Firefox isn't more tightly integrated into Ubuntu. Applications like Firefox and OpenOffice/Libreoffice are designed to work on a wide variety of operating environments including various Linux distributions, Desktop environments, Windows OS, Apple OS and many others. All of those environments are moving targets. For example Gnome has gone to GTK 3.0 but not every application in the latest Ubuntu release has upgraded from GTK 2.0 and of course let's not forget Unity has entered the fray. To that end Firefox and their ilk loosely couple with operating environments so that development can focus on the core features of the application. Being all things to all people or for applications in this case all environments can be destructive to core goals. Clearly tight integration is conceivable and desirable from an individual user's perspective. It's a matter of priorities and complexity. The desirability of regular concurrent releases for all environments is also a factor.

Solution 3:

There are different settings involved here:

  • What program Firefox proposes when downloading a file (as in the image posted in the question)

  • What program Firefox uses when accessing an online file

  • What program opens a file already downloaded when clicked in the Firefox downloads list.


For the first two options, the "Applications" settings under Preferences/Options (about:preferences as address) should do the trick (if it doesn't it is a bug and it should be reported as such).

Example for a deb file:

enter image description here

If the setting is to save, the file will be saved in Downloads or a selected location; if the setting is to open with an application, the file will be first saved anyway in a temporary location and then opened. If no program appears selected upon download try the above setting; if that doesn't work, try the below solution.


For the third case

(on how to make Firefox downloads list open a file in a desired application):

Some newly installed applications take over the "default" status in FF'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, Inskape or File Roller takes over instead of Okular for 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.


Something is not right with the Firefox settings. "Always ask" and "Save file" do not make sense for files already downloaded, therefore settings under about:preferences shouldn't affect the Downloads list. But they do. And they do in an inconsistent manner: only selecting the application marked as default is followed, switching to another application is not. To reverse that one might need to select "Always ask" and then follow the steps mentioned above.