As most applications use the mailcap and mime.types files (located in /etc/mailcap and /etc/mime.types) to determine file associations, we modified these files so that associations would be made for programs such as OpenOffice and Scribus. As one did not currently exist, we also created a mimetype for Scribus files and placed it in the mime.types file.
Unfortunately, Gnome and its associated applications (such as Nautilus and Evolution) completely ignore the mailcap file. For this reason, we had to also create file associations which Gnome would recognize. This is done via files in /usr/share/applications/defaults.list and /usr/share/mime-info.
We chose to modify the mailcap and mime.types files by including the appropirate files and changes in each individual program RPM. For example, the MPlayer RPM includes lines in the postinstall script to modify /etc/mailcap. A simple Unix re-direct is used here: echo --new line for mailcap here -- >> /etc/mailcap.
Here are some examples of what lines are added to mailcap in UBLinux.
application/scribus; scribus %s application/pdf; acroread %s application/postscript ; gv -safer %s audio/x-pn-realaudio; /usr/lib/RealPlayer9/realplay %s
Also add an appropriate entry to the/etc/mime.types file. The entry for scribus is given as an example:
application/scribus sla
Any entries in the Mailcap file will not affect most Gnome applications, such as Nautilus or Evolution. Instead, MIME information and file associations are drawn from files in /usr/share/mime-info, and the /usr/share/applications/defaults.list file.
The /usr/share/applications/defaults.list file defines what applications handle which mimetypes. Files within /usr/share/mime-info define what mime types correspond to what file extensions.
We added a file association for Scribus, an open source desktop publishing application. First, we need to define a MIME type. This is done via the file /usr/share/mime-info/scribus.mime:
application/scribus
ext: sla
There is also a file /usr/share/mime-info/scribus.keys which provides some additional information:
application/scribus
description=Scribus Document
default_action_type=application
default_application_id=scribus
short_list_application_ids_for_novice_user_level=scribus
category=Documents/Published Materials
use_category_default=yes
NOTE: The tabs must be present in the files as shown.
These two files tell Gnome that files with an ".sla" extension are a Scribus document with a MIME type of application/scribus. Next, the defaults.list file needs to be modified so scribus will be called when an sla file is opened. The line to be added will look something like this:
application/x-scribus=scribus.desktop
NOTE: Again, the tabs must be present as shown.
ALSO NOTE:You must have also defined the corresponding .desktop file for this method to work.
The .desktop files also comprise the GNOME menu entry. See the page on adding a menu entry to create the .desktop file. Modifying the
defaults.list file is NEW in Gnome 2.8 and higher. Older ways of defining mime-types (including
using the applications-registry directory) are present, but
are just ignored by GNOME.
For more information on this process, see this post.
Send questions or comments to ublinux-support@buffalo.edu
Last Modified 8/18/05