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:
* Which applications can open a file (_Mozilla can view files of type text/html_). This is defined in the <a href="http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html#id2926453">MimeTypes</a> key of the .desktop file of the application, see the desktop entry spec. * Which application should open a file by default (_Application X wants to be the default application for text/html after installation_) * How to let the user change the default application (_Bob wishes to view text/html files in Mozilla by default_).
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 thekey 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:
* Must provide a way to find a command to execute to view/edit/etc a file. * There should be support for multiple actions (view, edit, print, etc). * There must be some kind of priority system (Vim can view HTML, but should not be the default if a web browser is installed). * Internationalised descriptions of applications should not be repeated (Gimp should not have to specify translations of "Edit in Gimp" for every MIME type it supports). * There should be a way to overwrite the system defaults by user defaults. (eg. User a[dmin] will edit text files with vim and user b will use emacs) * There should be a way to choose a program for an action, therefore there must be made a list of the programs that can do this action to a file format. On this way you can open a file with a program that is not the default program for the file format.(eg. png editor is gimp but you want to test a new picture editor) * There should be a way to detect which environment is being used and how a file should be open (eg. editing a text file by choosing them with mc in a terminal should use a console based editor, but when mc runs in a xterm, an X-Window editor can also be used)
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.
* <a href="http://thread.gmane.org/gmane.linux.xdg.devel/2925">Shared mimetypes + activation thread</a> * <a href="http://thread.gmane.org/gmane.linux.xdg.devel/2524">Associating programs with file types thread</a> * <a href="http://thread.gmane.org/gmane.linux.xdg.devel/554">MIME activation discussion thread</a> * <a href="http://thread.gmane.org/gmane.linux.xdg.devel/2228">Default Program / File Association thread</a> (<a href="http://thread.gmane.org/gmane.linux.xdg.devel/2239">part II</a>) * <a href="http://thread.gmane.org/gmane.comp.freedesktop.xdg/9828">More recent Default Program / File Association thread, where mimeapps.list was introduced</a> * <a href="http://thread.gmane.org/gmane.comp.freedesktop.xdg/11520">Have a way to dynamically change software associations at distribution level</a>