Like some other desktop environments, GNOME comes with a set of pre-configured defaults to open files and launch applications, depending on the type of file. For instance, URLs will open by default in a Web browser, emails will open in a mail client, text files will open with a text editor. Depending on the applications installed and what distribution you are using, these defaults may vary and, more importantly, they may not be the defaults that you want.
Configuring default applications and associations in GNOME is easy. To change the global default application, go to System | Preferences | Preferred Applications. Here, you can set your preferred default browser, mail reader, multimedia player, various accessibility programs, and the default terminal application that you want to use. So if you prefer Thunderbird to the GNOME default of Evolution, you would make the change here.
Applications to open various file types are done through Nautilus. Open a Nautilus window and navigate to a file for which you want to change the default association. For example, the default for text files is to use the GEdit program, but if you prefer to associate .py (python) and .php (PHP) files with the Komodo IDE all the time, you need to change the default.
If you right-click on a .py file, you can use the "Open with Other Application" selection if this is a one-time association. If not, open the Properties selection. In the window that pops up, select the "Open With" tab. You should see any number of applications listed here, with the default being GEdit (a filled-in bullet indicates the default application to open the file with).
Click the "Add" button and scroll the list. If the application you want to use is listed, select it. If not, click the triangle beside the "Use a custom command" text string and either browse for the application or enter in the full path and filename to the application. To associate Komodo IDE to the .py file, type in the full path to the application, such as /usr/local/bin/komodo. Taken back to the "Open With" dialog, you will see the application listed, so select the radio button beside the application, then click the "Close" button.
In Nautilus, double-click the file to open it. A dialog will pop up asking how to handle the file, including if you want to run the file (this is because Nautilus knows this is a python file). Click the Display button instead, and Komodo will open with the file ready for editing.
At this point, Nautilus knows about Komodo, so if you take the above steps to assign Komodo as the default application for .php files, scroll in the list of applications and you will see Komodo is listed, which saves you a step in assigning the association.
This process can be used for any file type. If you prefer to have Totem as the default media player for every media type other than MP3 files, you can take the steps outlined above to assign something else to play MP3 files, but keep all other media types as the default preferred application of Totem.
Changing associations for differing file types is really easy. Taking the time to do this will make using GNOME, and the Nautilus file browser, much more enjoyable than being forced into default applications you don't care to use.
Get the PDF version of this tip here.
Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.