The routines in the gnome-mime-info allow
retrieval of information that has been bound to a given MIME type.
There are a number of standard keys used in GNOME to provide default
actions and behaviour.
To add keys to a MIME type, it is necessary to install a file with the
extension .keys in the
$gnome/share/mime-info directory or in the
~/.gnome/mime-info directory directory. The
former is for system-provided MIME information and the latter is to
enable the user to extend the actions as provided by the system.
The file $gnome/share/mime-info/gnome.keys is
special, as it contains the defaults for gnome, and is read first. In
addition, the file ~/.gnome/mime-info/user.keys is
read last. This will guarantee that there is a way to set system
defaults, and there is a way for the user to override them. There is
currently no way to tell anything about the order of the other files in
those directories, nor is there any way to override system defaults yet.
The .keys files have the following format:
Example 1. Format of a .keys file
Above, the key is the key that is being
defined, and value is the value we bind to
it. The optional [LANG] represents a
language in which this definition is valid. If this part is
specified, then the definition will only be valid if LANG matches the
setting of the environment variable LANG. The LANG setting is used to
provide keys which can be displayed to the user in a localized way.
This is an example to bind the key open to all of
the MIME types matching image/* and the
icon-filename key is bound to the
Example 2. Sample gimp.keys file
This will make the GIMP the handler for the open action. Files of
type xcf would use the filename pointed to in the icon-filename key.
f gets interpolated with the file name or the list of file names that
matched this MIME type.
As you can see from the example above, a
.keys file does not need to provide all of the
values, it can just provide or override some of the actions.
User defined bindings in .keys file will take
precedence over system installed files.
The following keys are currently used in the GNOME
open: Open the file with this
icon-filename: The filename
with the icon that should be used to represent files of this type.
view: Command to view the file
ascii-view: A command that
should be used to do an ascii-rendering of the file. Used as a
fallback by the filemanager if a view action
does not exist.
fm-open:file-manager open. If
present, the file manager will use this action instead of the value
in open to perform this action (the filemanager for example will
open archive files as if they were directories by using the VFS).
fm-view: file-manager view. If
present, invoking the view opertion on the file manager will use
the value defined here instead of the value in "view".
operation for the file manager as well.
Those keys are also queried on the metadata (except in the cases
where the lookup would be too expensive).