Specifications/mime-actions-spec

MIME actions

The freedesktop.org Shared MIME database provides a single way to store static information about MIME types and rules for determining a type.

In addition to this, three further pieces of information are often needed:

Status

This specification has been finalized through discussions on the xdg mailing-list, but no formal spec has been written (volunteers welcome).

Default application ordering

This hasn't been finalized in a cross-desktop way yet; especially since the default application is probably desktop specific in some cases. Discussions happened on the mailing-list about this (see thread "Have a way to dynamically change software associations at distribution level", links at bottom of this page).

The current status-quo is that KDE orders on the InitialPreference key in the .desktop files (higher = preferred), and gnome uses a global configuration file defaults.list. Effectively this makes the default ordering desktop-specific, but gives more work to distributions.

However, note that the next section provides another solution for ISV applications which want to ensure they become the default application after being installed: they can edit [or create] the global mimeapps.list file in /usr/share/applications. This is also a solution for system administrators who wish to set up a default application ordering for their users.

User-specified application ordering

Users can change the default order of applications by writing (using graphical tools, of course) into the file ~/.local/share/applications/mimeapps.list

The syntax of this file is:

[Added Associations]
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop;
mimetype2=foo4.desktop;
[Removed Associations]
mimetype1=foo5.desktop;

This means that foo1 is the preferred application for mimetype1, but if it is not installed then foo2 is going to be used, etc. It also means that if another application, say "new.desktop" is installed with mimetype1 in its mimetypes line, it will be at the fourth place in the list of applications associated with mimetype1 (it comes after the explicitely specified ones). On the other hand, the application foo5 was explicitely removed by the user, so it is not associated with mimetype1 anymore.

This mechanism allows for multiple levels of configuration, where mimeapps.list files override each other in XDG_DATA_DIRS directories. Sysadmin-provided settings can be overridden by user-local mimeapps.list files).

Non normative: Initial set of requirements, not all of which are covered by the current specification

Do not use any of this in implementations at this point, this was just input for the discussion.

The list of applications which can open files of a particular type is static information and should be stored in the MIME database, using some extension elements. The Adding to the MIME database tutorial provides a sample of how this might look. The extension element associates MIME entries with application .desktop files (eg, gimp.desktop). Issues to address:

Setting the default application:

Because this is configuration information, it should not go in the MIME database. Instead, it should be set using the Shared Configuration System. This specification should define a set of key names to be used for this.

References