NewMIMESystem

From FedoraProject

Jump to: navigation, search

The MIME system in GNOME 2.8 has been changed to match the freedesktop.org standard. In order for an application to register itself with the new MIME system it must install a .desktop file into /usr/share/applications with a MimeType= key containing a semicolon-delimited list of supported MIME types. For instance, a typical .desktop file might look like:

[Desktop Entry] 
Name=Cool Image Viewer
Encoding=UTF-8
Exec=cool-image-viewer %f
MimeType=image/png;image/jpeg;

The Exec= key can contain a substitution variable specifying the type of parameter the application can take. If the application expects a file path to be passed to it then %f should be used. If the application expects a URI then %u should be used. If the application can accept multiple file paths or URIs then the uppercase variants, %F and %U should be used instead, respectively.

In order to refresh the MIME-type/application mapping cache (mimeinfo.cache), the update-desktop-database program must be run after the .desktop file is installed. When packaging programs that register with the new MIME system, it is best to call update-desktop-database from the %post and %postun sections of the RPM's .spec file. Example:

%post
update-desktop-database &> /dev/null || :

%postun
update-desktop-database &> /dev/null || :

The spec file should not Require desktop-file-utils for this (it used to be required in old Fedora Core releases).