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:

MimeType=image/png

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 Exemplo 1-2.

Exemplo 1-2Sample file for registering a new MIME type
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
   <mime-type type="application/x-example">
     <comment>Tipo de ficheiro de exemplo </comment>
     <magic priority="50">
       <match value="search-string" type="string" offset="10:140"/>
     </magic>
     <glob pattern="*.newextension"/>
   </mime-type>
</mime-info>

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

Para obter máis información sobre elixir unha boa extensión MIME e rexistrar o seu tipo MIME, vaia á páxina web da IANA.

1.3.1. Referencias

Especificación de información de tipos MIME: Describe o sistema de rexistro de tipos MIME en detalle.