Adding MIME types

If your application can open specific MIME types, you need to let the desktop know in the desktop file. For example, if your application can accept PNG files, add the following line into your desktop file:


Additional Mime types can be added by separating the different types with semicolons.

The system already knows of a large number of MIME types. However, if you are creating one of your own, you need to register your MIME type into the MIME database. In the /usr/share/mime/packages/ directory, create an XML file with the format as shown in Example 1-2.

Example 1-2Sample file for registering a new MIME type
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="">
   <mime-type type="application/x-example">
     <comment>Example file type </comment>
     <magic priority="50">
       <match value="search-string" type="string" offset="10:140"/>
     <glob pattern="*.newextension"/>

In this example, replace the example MIME type with the name of your MIME type. The magic section searches files for the search string for identification. The glob line uses the suffix of file names for identification.

Because the magic command forces the computer to open the files to search for the string, the glob command is preferable.

Once your new MIME type is adequately described in the file, run the following in a shell:

update-mime-database /usr/share/mime

For more information on choosing a good MIME extension and to register your MIME type, go to the IANA website.

1.3.1. References

Shared MIME Info Specification — Describes the MIME registration system in detail.