Change the default download action in firefox to gnome-open

when a file is downloaded off the internet, most of the time the webserver announces it as an unknown binary file to be downloaded by passing the Content-Type header for “application/octet-stream”. Unfortunately, firefox does not cope with that very well as it fails to manage how such “unknown” files are opened. On most of my Xubuntu installs it simply opens it with gedit which is of course pretty annoying if you donwload a 250MB Zip file for instance.

instead it would be much nicer to have it open these files with gnome-open since this is the program that determins how a file is opened when you double click it in gnome. In other words, once you tell firefox to open octetstream files with gnome-open you will only have to choose in one place how to open a zip or a pdf and it will be opened the same way in your os or from your browser. sounds good doesn't it? :)

so here is how to achieve that:

Perpare a .desktop file for gnome-open

check your ~/.local/share/applications/ and see if you have a .desktop file for gnome-open already. maybe use grep for that purpose:

grep gnome-open ~/.local/share/applications/* 

if you don't find a .desktop file, create one (like gnome-open.desktop) in that folder with the following content:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=gnome-open %f
Name=gnome-open
Comment=Custom definition for gnome-open
NoDisplay=true

set the default app for application-octetstream

unfortunately firefox doesn't provide a nice gui solution to set the default application for an octet stream, so you need to edit a file in your home directory to do that:

nano ~/.local/share/applications/mimeapps.list

now search for

application/octet-stream

and set it to gnome-open.desktop like this:

application/octet-stream=gnome-open.desktop

do this for all occurrences of octet-stream and if you don't find any, add it under the [Added Associations] section