codekasten/gnome-menu/zweit-versuch/doku/desktop-entry-spec-0.9.4.html

554 lines
43 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Desktop Entry Specification</title><meta name="generator" content="DocBook XSL Stylesheets V1.64.1" /><link rel="home" href="#index" title="Desktop Entry Specification" /><link rel="next" href="#introduction" title="Introduction" /></head><body><div class="article" lang="en" xml:lang="en"><div class="titlepage"><div><div><h1 class="title"><a id="index"></a>Desktop Entry Specification</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Preston</span> <span class="surname">Brown</span></h3><div class="affiliation"><div class="address"><p><br />
    <tt class="email">&lt;<a href="mailto:pbrown@kde.org">pbrown@kde.org</a>&gt;</tt><br />
  </p></div></div></div><div class="author"><h3 class="author"><span class="firstname">Jonathan</span> <span class="surname">Blandford</span></h3><div class="affiliation"><div class="address"><p><br />
    <tt class="email">&lt;<a href="mailto:jrb@redhat.com">jrb@redhat.com</a>&gt;</tt><br />
  </p></div></div></div><div class="author"><h3 class="author"><span class="firstname">Owen</span> <span class="surname">Taylor</span></h3><div class="affiliation"><div class="address"><p><br />
    <tt class="email">&lt;<a href="mailto:otaylor@gtk.org">otaylor@gtk.org</a>&gt;</tt><br />
  </p></div></div></div></div></div><div><p class="releaseinfo">Version 0.9.4</p></div></div><div></div><hr /></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#introduction">Introduction</a></span></dt><dt><span class="sect1"><a href="#basic-format">Basic format of the file</a></span></dt><dt><span class="sect1"><a href="#value-types">Possible value types</a></span></dt><dt><span class="sect1"><a href="#recognized-keys">Recognized desktop entry keys</a></span></dt><dt><span class="sect1"><a href="#character-encoding">Character set encoding of the file</a></span></dt><dt><span class="sect1"><a href="#exec-variables">List of valid Exec parameter variables</a></span></dt><dt><span class="sect1"><a href="#mime-types">Registering MIME Types</a></span></dt><dd><dl><dt><span class="sect2"><a href="#mime-caching">Caching MIME Types</a></span></dt><dt><span class="sect2"><a href="#mime-priority">Priority of MIME Types and desktop files</a></span></dt></dl></dd><dt><span class="sect1"><a href="#extending">Extending the format</a></span></dt><dt><span class="appendix"><a href="#example">A. Example Desktop Entry File</a></span></dt><dt><span class="appendix"><a href="#kde-items">B. Currently reserved for use within KDE</a></span></dt><dt><span class="appendix"><a href="#deprecated-items">C. Deprecated Items</a></span></dt><dt><span class="appendix"><a href="#legacy-mixed">D. The Legacy-Mixed Encoding (Deprecated)</a></span></dt></dl></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="introduction"></a>Introduction</h2></div></div><div></div></div><p>
Both the KDE and GNOME desktop environments have adopted a similar
format for "desktop entries", or configuration files describing how a
particular program is to be launched, how it appears in menus, etc.
It is to the larger community's benefit that a unified standard be
agreed upon by all parties such that interoperation between the two
environments, and indeed any additional environments that implement
the specification, becomes simpler.
</p></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="basic-format"></a>Basic format of the file</h2></div></div><div></div></div><p>
These desktop entry files should have the extension
<tt class="filename">.desktop</tt>. Determining file type on basis of
extension makes determining the file type very easy and quick.
When no file extension is present, the desktop system should
fall back to recognition via "magic detection". Desktop entries
which describe how a directory is to be formatted/displayed
should be simply called <tt class="filename">.directory</tt>.
</p><p>
The basic format of the desktop entry file requires that there be
a "group" header named <tt class="literal">[Desktop Entry]</tt>. This
"group" entry denotes that all <tt class="literal">{key,value}</tt>
pairs following it belong in the Desktop Entry group. There may
be other groups present in the file, but this is the most
important group which explicitly needs to be supported. This
group should also be used as the "magic key" for automatic MIME
type detection. There should be nothing proceeding this group in
the desktop entry file but possibly one or more comments (see
below).
</p><p>
Group headers may not contain the characters <tt class="literal">[</tt> and
<tt class="literal">]</tt> as those delimit the header.
</p><p>
Lines beginning with a <tt class="literal">#</tt> and blank lines are
considered comments and will be ignored, however they should be
preserved across reads and writes of the desktop entry file.
</p><p>
Compliant implementations MUST not remove any fields from the file,
even if they don't support them. Such fields must be maintained in a
list somewhere, and if the file is "rewritten", they will be included.
This ensures that any desktop-specific extensions will be preserved
even if another system accesses and changes the file.
</p><p>
Entries in the file are <tt class="literal">{key,value}</tt> pairs in the format:
</p><pre class="programlisting">Key=Value</pre><p>
Space before and after the equals sign should be ignored; the <tt class="literal">=</tt>
sign is the actual delimiter.
</p><p>
The escape sequences <tt class="literal">\s</tt>, <tt class="literal">\n</tt>,
<tt class="literal">\t</tt>, <tt class="literal">\r</tt>, and
<tt class="literal">\\</tt> are supported, meaning ASCII space, newline,
tab, carriage return, and backslash, respectively.
</p></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="value-types"></a>Possible value types</h2></div></div><div></div></div><p>
The value types recognized are string, localestring, regexp,
boolean (encoded as the string true/false), and numeric.
</p><p>
Values of type <tt class="literal">string</tt> must contain only ASCII
characters excluding control characters. Values of type
<tt class="literal">localestring</tt> are user displayable, and are
encoded in UTF-8 unless the <tt class="constant">Legacy-Mixed</tt>
Encoding is specified (see <a href="#legacy-mixed" title="D. The Legacy-Mixed Encoding (Deprecated)">Appendix D, <i>The Legacy-Mixed Encoding (Deprecated)</i></a>.)
</p><p>
Some keys can have multiple values; these should be separated by a
semicolon. Those keys which have several values should have a
semicolon as the trailing character. Semicolons in these values
need to be escaped using <tt class="literal">\;</tt>.
</p></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="recognized-keys"></a>Recognized desktop entry keys</h2></div></div><div></div></div><p>
Keys with type localestring may be postfixed by [<i class="replaceable"><tt>LOCALE</tt></i>],
where <i class="replaceable"><tt>LOCALE</tt></i> is the locale type of the
entry. <i class="replaceable"><tt>LOCALE</tt></i> must be of the form
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i>.<i class="replaceable"><tt>ENCODING</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>,
where
<tt class="literal">_<i class="replaceable"><tt>COUNTRY</tt></i></tt>,
<tt class="literal">.<i class="replaceable"><tt>ENCODING</tt></i></tt>,
and <tt class="literal">@<i class="replaceable"><tt>MODIFIER</tt></i></tt>
may be omitted. If a postfixed key occurs, the same
key must be also present without the postfix.
</p><p>
When reading in the desktop entry file, the value of the key is
selected by matching the current POSIX locale for the
<tt class="varname">LC_MESSAGES</tt> category against the
<i class="replaceable"><tt>LOCALE</tt></i> postfixes of all occurrences
of the key, with the
<tt class="literal">.<i class="replaceable"><tt>ENCODING</tt></i></tt> part
stripped. The
<tt class="literal">.<i class="replaceable"><tt>ENCODING</tt></i></tt> field is
used only when the value of the <tt class="varname">Encoding</tt> key
for the desktop entry file is <tt class="constant">Legacy-Mixed</tt>
(see <a href="#legacy-mixed" title="D. The Legacy-Mixed Encoding (Deprecated)">Appendix D, <i>The Legacy-Mixed Encoding (Deprecated)</i></a>.)
</p><p>
The matching of is done as follows. If
<tt class="varname">LC_MESSAGES</tt> is of the form
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i>.<i class="replaceable"><tt>ENCODING</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>,
then it will match a key of the form
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>.
If such a key does not exist, it will attempt to match
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i></tt>
followed by
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>.
Then, a match against <i class="replaceable"><tt>lang</tt></i> by itself
will be attempted. Finally, if no matching key is found the
required key without a locale specified is used. The encoding
from the <tt class="varname">LC_MESSAGES</tt> value is ignored
when matching.
</p><p>
If <tt class="varname">LC_MESSAGES</tt> does not have a <i class="replaceable"><tt>MODIFIER</tt></i>
field, then no key with a modifier will be matched. Similarly, if
<tt class="varname">LC_MESSAGES</tt> does not have a <i class="replaceable"><tt>COUNTRY</tt></i>
field, then no key with a country specified will be matched. If
<tt class="varname">LC_MESSAGES</tt> just has a <i class="replaceable"><tt>lang</tt></i> field, then
it will do a straight match to a key with a similar value. The
following table lists possible matches of various <tt class="varname">LC_MESSAGES</tt> values in
the order in which they are matched. Note that the
<i class="replaceable"><tt>ENCODING</tt></i> field isn't shown.
</p><div class="table"><a id="id2444249"></a><p class="title"><b>Table 1. Locale Matching</b></p><table summary="Locale Matching" border="1"><colgroup><col /><col /></colgroup><thead><tr><th><tt class="varname">LC_MESSAGES</tt> value</th><th>Possible keys in order of matching</th></tr></thead><tbody><tr><td><tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt></td><td><tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>,
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i></tt>,
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>,
<tt class="literal"><i class="replaceable"><tt>lang</tt></i></tt>,
default value
</td></tr><tr><td><tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i></tt></td><td><tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i></tt>,
<i class="replaceable"><tt>lang</tt></i>,
default value
</td></tr><tr><td><tt class="literal"><i class="replaceable"><tt>lang</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt></td><td><tt class="literal"><i class="replaceable"><tt>lang</tt></i>@<i class="replaceable"><tt>MODIFIER</tt></i></tt>,
<i class="replaceable"><tt>lang</tt></i>,
default value
</td></tr><tr><td><i class="replaceable"><tt>lang</tt></i></td><td><i class="replaceable"><tt>lang</tt></i>,
default value
</td></tr></tbody></table></div><p>
For example, if the current value of the <tt class="varname">LC_MESSAGES</tt> category
is <tt class="literal">sr_YU@Latn</tt> and the desktop file includes:
</p><pre class="programlisting">
Name=Foo
Name[sr_YU]=...
Name[sr@Latn]=...
Name[sr]=...</pre><p>
then the value of the <tt class="varname">Name</tt> keyed by <tt class="literal">sr_YU</tt> is used.
</p><p>
Case is significant. The keys <tt class="varname">Name</tt> and <tt class="varname">NAME</tt> are not equivalent.
The same holds for group names. Key values are case sensitive as
well.
</p><p>
Keys are either OPTIONAL or REQUIRED. If a key is optional it may or
may not be present in the file. However, if it isn't, the
implementation of the standard should not blow up, it must provide
some sane defaults. Additionally, keys either MUST or MAY be
supported by a particular implementation.
</p><p>
Some keys only make sense in the context when another particular key
is also present.
</p><p>
Some example keys: <tt class="varname">Name[C]</tt>, <tt class="varname">Comment[it]</tt>.
</p><div class="table"><a id="id2444496"></a><p class="title"><b>Table 2. Standard Keys</b></p><table summary="Standard Keys" border="1"><colgroup><col /><col /><col /><col /><col /></colgroup><thead><tr><th>Key</th><th>Description</th><th>Value Type</th><th>REQ?</th><th>MUST?</th><th>Type</th></tr></thead><tbody><tr><td><a id="key-type"></a><tt class="varname">Type</tt></td><td>
There are 4 types of desktop entries:
<tt class="constant">Application</tt>,
<tt class="constant">Link</tt>, <tt class="constant">FSDevice</tt>
and <tt class="constant">Directory</tt>.
</td><td>string</td><td>YES</td><td>YES</td></tr><tr><td><a id="key-version"></a><tt class="varname">Version</tt></td><td>
Version of Desktop Entry Specification
(While the version field is not required to be present,
it should be in all newer implementations of the Desktop
Entry Specification. If the version number is not
present, a "pre-standard" desktop entry file is to be
assumed).
</td><td>numeric</td><td>NO</td><td>YES</td><td>1-4</td></tr><tr><td><a id="key-encoding"></a><tt class="varname">Encoding</tt></td><td>
Encoding of the whole desktop entry file
(<tt class="constant">UTF-8</tt> or
<tt class="constant">Legacy-Mixed</tt>).
</td><td>string</td><td>YES</td><td>YES</td><td>1-4</td></tr><tr><td><a id="key-name"></a><tt class="varname">Name</tt></td><td>
Specific name of the application, for example "Mozilla".
</td><td>localestring</td><td>YES</td><td>YES</td><td>1-4</td></tr><tr><td><a id="key-genericname"></a><tt class="varname">GenericName</tt></td><td>
Generic name of the application, for example "Web Browser".
</td><td>localestring</td><td>NO</td><td>YES</td><td>1-4</td></tr><tr><td><a id="key-nodisplay"></a><tt class="varname">NoDisplay</tt></td><td><tt class="varname">NoDisplay</tt> means "this application exists, but don't display it in the menus".
This can be useful to e.g. associate this application with MIME types, so that
it gets launched from a file manager (or other apps), without having a menu
entry for it (there are tons of good reasons for this, including e.g. the
<tt class="literal">netscape -remote</tt>, or <tt class="literal">kfmclient openURL</tt> kind of stuff).
</td><td>boolean</td><td>NO</td><td>NO</td><td>1-4</td></tr><tr><td><a id="key-comment"></a><tt class="varname">Comment</tt></td><td>
Tooltip for the entry, for example "View sites on the
Internet", should not be redundant with <tt class="varname">Name</tt> or
<tt class="varname">GenericName</tt>.
</td><td>localestring</td><td>NO</td><td>YES</td><td>1-4</td></tr><tr><td><a id="key-icon"></a><tt class="varname">Icon</tt></td><td>
Icon to display in file manager, menus, etc. If the
name is an absolute path, the given file will be
used. If the name is not an absolute path, an
implementation-dependent search algorithm will be used
to locate the icon. Icons may be localized with the
<tt class="literal">Icon[xx]=</tt> syntax.
</td><td>string</td><td>NO</td><td>YES</td><td>1-4</td></tr><tr><td><a id="key-hidden"></a><tt class="varname">Hidden</tt></td><td><tt class="varname">Hidden</tt> should have been called <tt class="varname">Deleted</tt>.
It means the user deleted (at his level)
something that was present (at an upper level, e.g. in the system dirs). It's
strictly equivalent to the <tt class="filename">.desktop</tt> file not existing at all, as far as that user is
concerned. This can also be used to "uninstall" existing files (e.g. due to a renaming)
- by letting <tt class="literal">make install</tt> install a file with <tt class="literal">Hidden=true</tt> in it.
</td><td>boolean</td><td>NO</td><td>NO</td><td>1-4</td></tr><tr><td><a id="key-filepattern"></a><tt class="varname">FilePattern</tt></td><td>
A list of regular expressions to match against for a
file manager to determine if this entry's icon should be
displayed. Usually simply the name of the main
executable and friends.
</td><td>regexp(s)</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-tryexec"></a><tt class="varname">TryExec</tt></td><td>
File name of a binary on disk used to determine if the
program is actually installed. If not, entry may not
show in menus, etc.
</td><td>string</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-exec"></a><tt class="varname">Exec</tt></td><td>
Program to execute, possibly with arguments.
</td><td>string</td><td>NO</td><td>YES</td><td>1</td></tr><tr><td><a id="key-path"></a><tt class="varname">Path</tt></td><td>
If entry is of type <tt class="constant">Application</tt>, the working directory to run the program in.
</td><td>string</td><td>NO</td><td>YES</td><td>1</td></tr><tr><td><a id="key-terminal"></a><tt class="varname">Terminal</tt></td><td>
Whether the program runs in a terminal window.
</td><td>boolean</td><td>NO</td><td>YES</td><td>1</td></tr><tr><td><a id="key-swallowtitle"></a><tt class="varname">SwallowTitle</tt></td><td>
If entry is swallowed onto the panel, this should be the title of the window.
</td><td>localestring</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-swallowexec"></a><tt class="varname">SwallowExec</tt></td><td>
Program to exec if swallowed app is clicked.
</td><td>string</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-actions"></a><tt class="varname">Actions</tt></td><td>
Additional actions possible, see MIME type discussion in <a href="#mime-types" title="Registering MIME Types">the section called “Registering MIME Types”</a>.
</td><td>string(s)</td><td>NO</td><td>YES</td><td>1</td></tr><tr><td><a id="key-mimetype"></a><tt class="varname">MimeType</tt></td><td>
The MIME type(s) supported by this entry.
</td><td>strings(s)</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-sortorder"></a><tt class="varname">SortOrder</tt></td><td>
This may specify the order in which to display files.
</td><td>string(s)</td><td>NO</td><td>NO</td><td>4</td></tr><tr><td><a id="key-dev"></a><tt class="varname">Dev</tt></td><td>
The device to mount.
</td><td>string</td><td>NO</td><td>NO</td><td>3</td></tr><tr><td><a id="key-fstype"></a><tt class="varname">FSType</tt></td><td>
The type of file system to try to mount.
</td><td>string</td><td>NO</td><td>NO</td><td>3</td></tr><tr><td><a id="key-mountpoint"></a><tt class="varname">MountPoint</tt></td><td>
The mount point of the device in question.
</td><td>string</td><td>NO</td><td>NO</td><td>3</td></tr><tr><td><a id="key-readonly"></a><tt class="varname">ReadOnly</tt></td><td>
Specifies whether or not the device is read only.
</td><td>boolean</td><td>NO</td><td>NO</td><td>3</td></tr><tr><td><a id="key-unmounticon"></a><tt class="varname">UnmountIcon</tt></td><td>
Icon to display when device is not mounted. Mounted devices display icon from the <tt class="varname">Icon</tt> key.
<tt class="varname">UnmountIcon</tt>s may be localized with the <tt class="literal">UnmountIcon[xx]=</tt> syntax.
</td><td>string</td><td>NO</td><td>NO</td><td>3</td></tr><tr><td><a id="key-url"></a><tt class="varname">URL</tt></td><td>
If entry is Link type, the URL to access.
</td><td>string</td><td>NO</td><td>YES</td><td>2</td></tr><tr><td><a id="key-categories"></a><tt class="varname">Categories</tt></td><td>
Categories in which the entry should be shown in a menu (for
possible values see the <a href="http://www.freedesktop.org/Standards/menu-spec" target="_top">Desktop
Menu Specification</a>).
</td><td>string(s)</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-onlyshowin"></a><tt class="varname">OnlyShowIn</tt>, <tt class="varname">NotShowIn</tt></td><td>
A list of strings identifying the environments that should
display/not display a given desktop entry. Only one of
these keys, either <tt class="varname">OnlyShowIn</tt> or
<tt class="varname">NotShowIn</tt>, may appear in a group (for
possible values see the <a href="http://www.freedesktop.org/Standards/menu-spec" target="_top">Desktop
Menu Specification</a>).
</td><td>string(s)</td><td>NO</td><td>NO</td><td>1-4</td></tr><tr><td><a id="key-startupnotify"></a><tt class="varname">StartupNotify</tt></td><td>
If true, it is KNOWN that the application will send a "remove"
message when started with the <tt class="envar">DESKTOP_LAUNCH_ID</tt> environment variable
set (see the <a href="http://www.freedesktop.org/Standards/startup-notification-spec" target="_top">Startup Notification Protocol Specification</a> for more details).
</td><td>boolean</td><td>NO</td><td>NO</td><td>1</td></tr><tr><td><a id="key-startupwmclass"></a><tt class="varname">StartupWMClass</tt></td><td>
If true, it is KNOWN that the application will map at least one
window with the given string as its WM class or WM name hint (see the <a href="http://www.freedesktop.org/Standards/startup-notification-spec" target="_top">Startup Notification Protocol Specification</a> for more details).
</td><td>string</td><td>NO</td><td>NO</td><td>1</td></tr></tbody></table></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="character-encoding"></a>Character set encoding of the file</h2></div></div><div></div></div><p>
Desktop entry files are encoded as lines of 8-bit characters separated
by LF characters.
</p><div class="itemizedlist"><ul type="disc"><li><p>
Key names must contain only the characters <tt class="literal">A-Za-z0-9-</tt>
</p></li><li><p>
Group names may contain all ASCII characters except for
<tt class="literal">[</tt> and <tt class="literal">]</tt> and control characters.
</p></li><li><p>
Values of type string may contain all ASCII characters except
for control characters.
</p></li><li><p>
Values of type boolean must either be the string <tt class="literal">true</tt> or
<tt class="literal">false</tt>.
</p></li><li><p>
Numeric values must be a valid floating point number as recognized
by the <tt class="literal">%f</tt> specifier for <tt class="function">scanf</tt>.
</p></li></ul></div><p>
Comment lines are uninterpreted and may contain any character
(except for LF). However, using UTF-8 for comment lines that
contain characters not in ASCII is encouraged.
</p><p>
The encoding for values of type localestring is determined by the
<tt class="varname">Encoding</tt> field.
</p></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="exec-variables"></a>List of valid <tt class="varname">Exec</tt> parameter variables</h2></div></div><div></div></div><p>
Each <tt class="varname">Exec</tt> field may take a number of arguments which will be
expanded by the file manager or program launcher and passed to the
program if necessary.
</p><p>
Literal <tt class="literal">%</tt> characters must be escaped as <tt class="literal">%%</tt>, and adding new
format characters is not allowed. It's a fatal error to have an
<tt class="varname">Exec</tt> field with a format character not given in the spec (exception
to this are the deprecated format characters which can be ignored,
that is expanded to no parameters, by the implementation).
Again for emphasis: <span class="emphasis"><em>nonstandard extensions are
not allowed here - you must add an <tt class="varname">X-Foo-Exec</tt> field if you have
nonstandard <tt class="varname">Exec</tt> lines</em></span>.
</p><p>
The escaping of the exec parameters is done in the way the mailcap
specification describes. Take a look at
<a href="http://www.ietf.org/rfc/rfc1524" target="_top">RFC 1524</a>
for more information.
</p><p>
Recognized fields are as follows:
</p><div class="informaltable"><table border="1"><colgroup><col /><col /></colgroup><tbody><tr><td><tt class="literal">%f</tt></td><td>
A single file name, even if multiple files are selected. The system
reading the desktop entry should recognize that the program in
question cannot handle multiple file arguments, and it should
should probably spawn and execute multiple copies of a program
for each selected file if the program is not able to handle
additional file arguments. If files are not on the local file system
(i.e. are on HTTP or FTP locations), the files will be copied to the local
file system and <tt class="literal">%f</tt> will be expanded to point at the temporary
file. Used for programs that do not understand the URL syntax.
</td></tr><tr><td><tt class="literal">%F</tt></td><td>
A list of files. Use for apps that can open several local
files at once.
</td></tr><tr><td><tt class="literal">%u</tt></td><td>
A single URL.
</td></tr><tr><td><tt class="literal">%U</tt></td><td>
A list of URLs.
</td></tr><tr><td><tt class="literal">%d</tt></td><td>
Directory containing the file that would be passed in a <tt class="literal">%f</tt> field.
</td></tr><tr><td><tt class="literal">%D</tt></td><td>
List of directories containing the files that would be
passed in to a <tt class="literal">%F</tt> field.
</td></tr><tr><td><tt class="literal">%n</tt></td><td>
A single filename (without path).
</td></tr><tr><td><tt class="literal">%N</tt></td><td>
A list of filenames (without paths).
</td></tr><tr><td>%i</td><td>
The <tt class="varname">Icon</tt> field of the desktop entry
expanded as two parameters, first
<tt class="literal">--icon</tt> and then the contents of the
<tt class="varname">Icon</tt> field. Should not expand as any
parameters if the <tt class="varname">Icon</tt> field is empty
or missing.
</td></tr><tr><td><tt class="literal">%c</tt></td><td>
The translated <tt class="varname">Name</tt> field associated with the desktop entry.
</td></tr><tr><td><tt class="literal">%k</tt></td><td>
The location of the desktop file as either a URI (if for
example gotten from the vfolder system) or a local
filename or empty if no location is known.
</td></tr><tr><td><tt class="literal">%v</tt></td><td>
The name of the <tt class="varname">Device</tt> entry in the desktop file.
</td></tr></tbody></table></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="mime-types"></a>Registering MIME Types</h2></div></div><div></div></div><p>
The <tt class="varname">MimeType</tt> key is used to indicate the MIME
Types that an application knows how to handle. Applications that
can handle multiple MIME Types would list all of the ones it can
handle in a ';' separated list, as normal. It is expected that
for some applications this list could become long. An application
is expected to be able to reasonably open files of these types
using the command listed in the <tt class="varname">Exec</tt> keyword.
</p><p>
There should be no priority for MIME Types in this field, or any
form of priority in the desktop file. Priority for applications
is handled external to the <tt class="filename">.desktop</tt> files.
</p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="mime-caching"></a>Caching MIME Types</h3></div></div><div></div></div><p>
To make parsing of all the desktop files less costly, a
<span><b class="command">update-desktop-database</b></span> program is provided
that will generate a cache file. The concept is identical to
that of the 'update-mime-database' program in that it lets
applications avoid reading in (potentially) hundreds of files.
It will need to be run after every desktop file is installed.
One cache file is created for every directory in
$XDG_DATA_DIRS/applications/, and will create a file called
$XDG_DATA_DIRS/applications/mimeinfo.cache.
</p><p>
The format of the cache is similar to that of the desktop file,
and is just a list mapping mime-types to desktop files. Here's
a quick example of what it would look like:
</p><pre class="programlisting">application/x-foo=foo.desktop;bar.desktop;
application/x-bar=bar.desktop;</pre><p>
Each MIME Type is listed only once per cache file, and the
desktop-id is expected to exist in that particular directory.
That is to say, if the cache file is located at
<tt class="filename">/usr/share/applications/mimeinfo.cache</tt>,
bar.desktop refers to the file
<tt class="filename">/usr/share/applications/bar.desktop</tt>.
</p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="mime-priority"></a>Priority of MIME Types and desktop files</h3></div></div><div></div></div><p>
There is also a preference list to determine preferred
application of a given MIME Type. It defines the 'default'
application to handle a given MIME Type. It has the same format
as the cache list.
</p><pre class="programlisting">mime/type=desktop-id.desktop;</pre><p>
If a mime type is listed multiple times (either in the same
file, or in another file further down the search path), the
latter mention wins. If a listed file doesn't exist, or is
precluded through the <tt class="varname">OnlyShowIn</tt> or
<tt class="varname">NotShowIn</tt> files, they should be ignored.
This means that applications will have to keep a history of the
preferred applications that they run into, so that if the top
desktop file for a given MIME Type isn't available, the second
one can be tested, etc.
</p><p>
It is also worth noting who this mechanism is defined for. It
is primarily intended for use by distributors/sysadmins to
provide a sane set of defaults for their users. Additionally,
users themselves can use this mechanism to override the user
defaults. We intentionally don't provide a way for application
authors themselves to list themselves as the default for a given
type, as we felt that that cannot work.
</p></div></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="extending"></a>Extending the format</h2></div></div><div></div></div><p>
If the standard is to be amended with a new <tt class="literal">{key,value}</tt> pair which
should be applicable to all supporting parties, a group discussion
will take place. This is the preferred method for introducing
changes. If one particular party wishes to add a field for personal
use, they should prefix the key with the string <tt class="varname">X-<i class="replaceable"><tt>PRODUCT</tt></i></tt>,
e.g. <tt class="varname">X-NewDesktop-Foo</tt>, following the precedent set by other IETF and RFC
standards.
</p><p>
Alternatively, fields can be placed in their own group, where they may
then have arbitrary key names. If this is the case, the group should
follow the scheme outlined above,
i.e. <tt class="literal">[X-<i class="replaceable"><tt>PRODUCT</tt></i>
<i class="replaceable"><tt>GROUPNAME</tt></i>]</tt> or
something similar. These steps will avoid namespace clashes between
different yet similar environments.
</p></div><div class="appendix" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="example"></a>A. Example Desktop Entry File</h2></div></div><div></div></div><pre class="programlisting">
[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Name=Foo Viewer
Comment=The best viewer for Foo objects available!
TryExec=fooview
Exec=fooview %F
Icon=fooview.png
MimeType=image/x-foo
X-KDE-Library=libfooview
X-KDE-FactoryName=fooviewfactory
X-KDE-ServiceType=FooService
[Desktop Action Inverse]
Exec=fooview --inverse %f
Name=Foo Viewer (inverse image)
[Desktop Action Edit]
Exec=fooview --edit %f
Name=Foo Viewer (edit image)
Icon=fooview-edit.png</pre></div><div class="appendix" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="kde-items"></a>B. Currently reserved for use within KDE</h2></div></div><div></div></div><p>
During the time KDE added some extensions that are currently not
prefixed by the <tt class="literal">X-</tt> prefix, but should be in
future KDE releases.
</p><div class="itemizedlist"><ul type="disc"><li><p>
Keys added by KDE: <tt class="varname">ServiceTypes</tt>,
<tt class="varname">DocPath</tt>, <tt class="varname">Keywords</tt>,
<tt class="varname">InitialPreference</tt>
</p></li><li><p>
Types added by KDE: <tt class="constant">ServiceType</tt>, <tt class="constant">Service</tt>
</p></li></ul></div></div><div class="appendix" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="deprecated-items"></a>C. Deprecated Items</h2></div></div><div></div></div><p>
As this standard is quite old there are some deprecated items that
may or may not be used by several implementations.
</p><div class="itemizedlist"><ul type="disc"><li><p>
<tt class="literal">Type=MimeType</tt> is deprecated as there is a
new standard for this now, see the <a href="http://www.freedesktop.org/Standards/shared-mime-info-spec" target="_top">Shared
MIME-info Database specification</a> for more
information. In consequence the Keys
<tt class="varname">Patterns</tt> (various file name extensions
associated with the MIME type) and
<tt class="varname">DefaultApp</tt> (the default application
associated with this MIME type) are also deprecated.
</p></li><li><p>
Using <tt class="filename">.kdelnk</tt> instead of
<tt class="filename">.desktop</tt> as the file extension is
deprecated.
</p></li><li><p>
Using <tt class="literal">[KDE Desktop Entry]</tt> instead of
<tt class="literal">[Desktop Entry]</tt> as header is deprecated.
</p></li><li><p>
<tt class="literal">Encoding=Legacy-Mixed</tt>, which allowed
localestrings in the encoding of the specified locale, is
deprecated.
</p></li><li><p>
Deprecated <tt class="varname">Exec</tt> parameters:
<tt class="literal">%m</tt> (the mini-icon associated with the
desktop entry, this should be expanded as two parameters,
<tt class="literal">--miniicon</tt> and the content of the
<tt class="varname">MiniIcon</tt> field, it can also be ignored by
expanding it to no parameters).
</p></li><li><p>
Deprecated keys: <tt class="varname">MiniIcon</tt> (small icon for
menus, etc), <tt class="varname">TerminalOptions</tt> (if the
program runs in a terminal, any options that should be
passed to the terminal emulator before actually executing
the program), <tt class="varname">Protocols</tt>,
<tt class="varname">Extensions</tt>,
<tt class="varname">BinaryPattern</tt>,
<tt class="varname">MapNotify</tt>.
</p></li><li><p>
Historically some booleans have been represented by the numeric
entries <tt class="constant">0</tt> or <tt class="constant">1</tt>. With
this version of the standard they are now to be represented as a
boolean string. However, if an implementation is reading a pre-1.0
desktop entry, it should interpret <tt class="constant">0</tt> and
<tt class="constant">1</tt> as <tt class="constant">false</tt> and
<tt class="constant">true</tt>, respectively.
</p></li><li><p>
Historically lists have been comma separated. This is inconsistent with other lists which are separated by a semicolon. When reading a pre-1.0 desktop entry, comma separated lists should continue to be supported.
</p></li></ul></div></div><div class="appendix" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="legacy-mixed"></a>D. The <tt class="constant">Legacy-Mixed</tt> Encoding (Deprecated)</h2></div></div><div></div></div><p>
The <tt class="constant">Legacy-Mixed</tt> encoding corresponds to the traditional encoding
of desktop files in older versions of the GNOME and KDE desktop
files. In this encoding, the encoding of each localestring key
is determined by the locale tag for that key, if any. For keys
without a locale tag, the value must contain only ASCII
characters.
</p><p>
If the file specifies an unsupported encoding, the implementation
should either ignore the file, or, if the user has requested a direct
operation on the file (such as opening it for editing), display an
appropriate error indication to the user.
</p><p>
In the absence of an <tt class="varname">Encoding</tt> line, the implementation may choose
to autodetect the encoding of the file by using such factors
as:
</p><div class="itemizedlist"><ul type="disc"><li><p>
The location of the file on the file system
</p></li><li><p>
Whether the contents of the file are valid UTF-8
</p></li></ul></div><p>
If the implementation does not perform such auto-detection, it should
treat a file without an <tt class="varname">Encoding</tt> key in the same way as a file with an
unsupported <tt class="varname">Encoding</tt> Key.
</p><p>
If the locale tag includes an <tt class="literal">.<i class="replaceable"><tt>ENCODING</tt></i></tt> part, then that determines
the encoding for the line. Otherwise, the encoding is determined
by the language, or
<tt class="literal"><i class="replaceable"><tt>lang</tt></i>_<i class="replaceable"><tt>COUNTRY</tt></i></tt>
pair from the locale tag, according to the following table.
</p><div class="informaltable"><table border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Encoding</th><th>Aliases</th><th>Tags</th></tr></thead><tbody><tr><td>ARMSCII-8 (*)</td><td> </td><td>hy</td></tr><tr><td>BIG5</td><td> </td><td>zh_TW</td></tr><tr><td>CP1251</td><td> </td><td>be bg</td></tr><tr><td>EUC-CN</td><td>GB2312</td><td>zh_CN</td></tr><tr><td>EUC-JP</td><td> </td><td>ja</td></tr><tr><td>EUC-KR</td><td> </td><td>ko</td></tr><tr><td>GEORGIAN-ACADEMY (*)</td><td> </td><td> </td></tr><tr><td>GEORGIAN-PS (*)</td><td> </td><td>ka</td></tr><tr><td>ISO-8859-1</td><td> </td><td>br ca da de en es eu fi fr gl it nl no pt sv wa</td></tr><tr><td>ISO-8859-2</td><td> </td><td>cs hr hu pl ro sk sl sq sr</td></tr><tr><td>ISO-8859-3 </td><td> </td><td>eo</td></tr><tr><td>ISO-8859-5</td><td> </td><td>mk sp</td></tr><tr><td>ISO-8859-7</td><td> </td><td>el</td></tr><tr><td>ISO-8859-9</td><td> </td><td>tr</td></tr><tr><td>ISO-8859-13</td><td> </td><td>lt lv mi</td></tr><tr><td>ISO-8859-14</td><td> </td><td>cy ga</td></tr><tr><td>ISO-8859-15</td><td> </td><td>et</td></tr><tr><td>KOI8-R</td><td> </td><td>ru</td></tr><tr><td>KOI8-U</td><td> </td><td>uk</td></tr><tr><td>TCVN-5712 (*)</td><td>TCVN</td><td>vi</td></tr><tr><td>TIS-620</td><td> </td><td>th</td></tr><tr><td>VISCII</td><td> </td><td> </td></tr></tbody></table></div><div class="variablelist"><dl><dt><span class="term">Encoding</span></dt><dd><p>
The name given here is listed here is typically the
canonical name for the encoding in the GNU C Library's
<tt class="function">iconv</tt> facility. Encodings marked with (*) are not
currently supported by the GNU C Library; for this reason,
implementations may choose to ignore lines in desktop
files that resolve to this encoding. Desktop files with
these encodings are currently rare or non-existent.
</p></dd><dt><span class="term">Aliases</span></dt><dd><p>
Other names for the encoding found in existing desktop
files.
</p></dd><dt><span class="term">Tags</span></dt><dd><p>
Language tags for which this is the default encoding.
</p></dd></dl></div><p>
This table above covers all tags and encodings that are known to
be currently in use. Implementors may choose to support
encodings not in the above set. For tags without defaults listed
in the above table, desktop file creators must specify the
<tt class="literal">.<i class="replaceable"><tt>ENCODING</tt></i></tt> part of the locale tag.
</p><p>
Matching the <tt class="literal">.<i class="replaceable"><tt>ENCODING</tt></i></tt> part of the locale tag against a locale
name or alias should be done by stripping all punctuation
characters from both the tag and the name or alias, converting
both name and alias to lowercase, and comparing the result.
This is necessary because, for example, <tt class="literal">Big5</tt> is frequently
found instead of <tt class="literal">BIG5</tt> and <tt class="literal">georgianacademy</tt> instead of
<tt class="literal">GEORGIAN-ACADEMY</tt>. Desktop files creators should, however, use
the name as it appears in the "Encoding" column above.
</p></div></div></body></html>