Detailed discussion of supporting MIME types

Desktop Entry Standard
Prev |  | Next

# 7. Detailed discussion of supporting MIME types

It is in every desktop's best interest to have thorough support for mime types. The old /etc/mailcap and /etc/mime.types files are rather limited in scope and frankly, are outdated. Various desktop systems have come up with different ways of extending this original system, but none are compatible with each other. The Desktop Entry Standard hopes to be able to provide the beginnings of a solution to this problem.

At a very basic level, the "Exec" key provides the default action to take when the program described by a desktop entry is used to open a document or data file. Usually this consists of some action along the lines of "kedit %f" or "ee %f". This is a good start, but it isn't as flexible as it can be.

Let us first establish that a program which supports a MIME type or multiple mime types may be able to support multiple actions on those MIME types as well. The desktop entry may want to define additional actions in addition to the default. The toplevel "Exec" key describes the default action; Let us define this action to also be known as the "Open" action. Additional actions which might be possible include View, Edit, Play, etc. A further revision of this document will probably specify several "standard" actions in addition to the default "Open" action, but in all cases, the number of actions is arbitrary.

Let us use a sound player as a simple example. Call it sp. The default Exec (Open) action for this program would likely look something like:

    Exec=sp %u

However, imagine the sound player also supports editing of sound files in a graphical manner. We might wish to define an additional action which could accomodate this. Adding the action would be performed like this:

    Actions=Edit;

    [Desktop Action Edit]
    Exec=sp -edit %u

As you can see, defining the action "edit" will enable an additional group of the name [Desktop Action `actionname`] to be read. This group can contain an additional Exec line, as well as possibly other information like a new Name, Comment, Icon, and Path. Thus right-clicking on a .wav file will show both the default "Open" action and this "Edit" action to both be displayed as choices in the context-menu. A left click (double or single, whichever the file manager implements) would cause the default action to take place. These are implementation-specific details which are up to the implementer, and are not enforced by this standard.

If no DefaultApp is specified for a particular MIME type, any one of the programs registered which claim to be able to handle the MIME type may become the default handler. This behaviour is undefined and implementation-specific. KDE doesn't use a DefaultApp anymore, but assigns a Preference number to each program, so that the highest number is the one chosen for handling the MIME type.

Prev | Home | Next
List of valid Exec parameter variables |  | Extending the format