Oracle® Solaris 11.2 Desktop Administrator's Guide

Exit Print View

Updated: July 2014
 
 

How to Add or Modify MIME Types

  1. Create the Overrides.xml source XML file containing the definitions for the MIME types.
    • To set the definitions for all users, put the file in the /usr/share/mime/packages directory.
    • To set the definitions for an individual user, put the file in the ~/.local/share/mime/packages directory.

    If the file already exists, open it.

  2. Update the MIME database by running the update-mime-database command.
    • If you are setting the definitions for all users:
      # update-mime-database /usr/share/mime
    • If you are setting the definitions for an individual user:
      # update-mime-database ~/.local/share/mime/packages
  3. U pdate the MIME database by running the update-mime-database command.
    # update-mime-database /usr/share/mime
  4. Use the gnomevfs-info command to verify your changes .

    For example, the gnomevfs-info command displays the following output when you run the command for a SVG file. Note that the default application for this MIME type is eog.desktop.

    $ gnomevfs-info mime-diagram.svg
    Name              : mime-diagram.svg
    Type              : Regular
    MIME type         : image/svg+xml
    Default app       : eog.desktop
    Size              : 14869
    Blocks            : 32
    I/O block size	: 4096
    Local             : YES 
    SUID              : NO
    SGID				: NO
    Sticky            : NO
    Permissions       : 600644
    Link count        : 1
    UID               : 1000
    GID               : 100
    Access time       : Wed Feb 22 18:24:47 2006
    Modification time : Wed Feb 22 18:24:42 2006
    Change time       : Wed Feb 22 18:24:42 2006
    Device #          : 775
    Inode #           : 297252
    Readable		: YES
    Writable          : YES
    Executable        : NO
    $

    For more information about default applications, see Registering Applications for MIME Types.

Example 6-2  Creating an application/x-newtype MIME Type
  1. Create a new file, test.xyz, in your home directory.

  2. Use the gnomevfs-info command to find the file's MIME type.

    $ gnomevfs-info text.xyz

    The MIME type for this file should be detected as text/plain because no glob patterns or magic rules match the file.


    Note - When no glob patterns or magic rules match a file, then the file is resolved to the text/plain MIME type if the file contains textual data or application/octet-stream for binary data. If the file is empty, then the type is identified as text/plain MIME type.
  3. Create the Overrides.xml file or if the file already exists, modify the file.

    The sample XML file is as follows:

    <?xml version='1.0' encoding='utf-8'?>
    <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
    	<mime-type type="application/x-newtype"> 
    	<comment>new mime type</comment>
    	<glob pattern="*.xyz"/> 
    	</mime-type>
    </mime-info>
  4. Update the MIME database by using the update-mime-database command.

    # update-mime-database /usr/share/mime
  5. Use the gnomevfs-info command to verify that your change has taken effect.

    $gnomevfs-info testing.xyz | grep MIME
    MIME type : application/x-newtype

    You should see that the MIME type for the testing.xyz file is resolved as application/x-newtype.