JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris 11.1 Desktop Administrator's Guide     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  Administering the Oracle Solaris Desktop

2.  Managing User Preferences With GConf

3.  Customizing Menus

4.  Installing Themes

5.  Customizing Fonts

6.  Working With MIME Types

MIME Types Overview

About the MIME Database

MIME Database Contents

Refreshing the MIME Database

Understanding MIME Type XML Files

Modifying MIME Types

How to Add or Modify MIME Types

Registering Applications for MIME Types

How to Register Applications for MIME Types

How to Associate a MIME Type With an Application

7.  Managing Screensavers

8.  Managing Sessions

9.  Overview of the Yelp Help Browser

10.  Improving the Performance of the Oracle Solaris Desktop System

11.  Disabling Features in the Oracle Solaris Desktop System

12.  Working With the X Window System

A.  Hidden Directories

Glossary

Index

Modifying MIME Types

You should never directly modify the source XML files that are installed by applications in the <MIME>/packages directory. Instead, modify the Overrides.xml file. This file has precedence over all other source XML files installed into the same packages directory. If you are an application author, then this rule does not apply. Application authors should create a new source XML file and place the file in the <MIME>/packages directory.

You can modify the MIME database for all users on the system or for a particular user depending on the location of the file you change. To modify the database for all users, make changes to the file Overrides.xml in the $XDG_DATA_DIRS/mime/packages directory. To modify the database for a single user, make changes to the Overrides.xml file in the $XDG_DATA_HOME/mime/packages directory.

After changes are made, you must always run the update-mime-database application with the directory location of the MIME database as the first parameter.

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. Update 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.