Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

Registering Applications for MIME Types

Registering applications to handle MIME types is fairly straightforward. Applications are registered by creating a MimeType key in their .desktop entry file and listing each MIME type separated by a semicolon. The MimeType key should only be used in .desktop files whose Type key has the value “Application”. For more information on .desktop files, see the section called “Desktop Entry Files”.

After creating or modifying a .desktop entry file, you must update the application database using the update-desktop-database application (very similar to update-mime-database, except it does not take a parameter). This will create a mimeinfo.cache file in the applications subdirectory for each directory in $XDG_DATA_HOME:$XDG_DATA_DIRS. The cache file is necessary so that all the .desktop files do not need to be scanned for just the MimeType key, as this causes unnecessary disk I/O.

Default applications to use for specific MIME types should be specified in a file called defaults.list. This file is located in the applications subdirectory for each directory in $XDG_DATA_HOME and $XDG_DATA_DIRS. The format for this file consists of the MIME type, the = symbol and the Desktop File ID (which is the filename for the desktop entry file). Example 5.4, “A User's defaults.list file” is a short example of a defaults.list file in a user's ~/.local/share/applications directory.

Example 5.4. A User's defaults.list file

[Default Applications]
application/pdf=evince.desktop
text/html=epiphany.desktop
text/plain=gedit.desktop
image/jpeg=eog.desktop
image/png=eog.desktop
text/xml=gedit.desktop
XDG Desktop Entry Specification

How to register MIME types for applications is part of the XDG desktop entry specification, rather than the XDG shared mime info specification.


Previous
Modifying MIME types
GNOME 2.14 Desktop System Administration Guide Next
Adding an Application to the GNOME Desktop

 
 
  Published under the terms of the GNU General Public License Design by Interspire