<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>The Exec key</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="Desktop Entry Specification"><link rel="up" href="index.html" title="Desktop Entry Specification"><link rel="prev" href="ar01s05.html" title="Recognized desktop entry keys"><link rel="next" href="ar01s07.html" title="Registering MIME Types"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The <code class="varname">Exec</code> key</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s05.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ar01s07.html">Next</a></td></tr></table><hr></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="exec-variables"></a>The <code class="varname">Exec</code> key</h2></div></div></div><p>
The <code class="varname">Exec</code> key must contain a command line.
A command line consists of an executable program optionally followed
by one or more arguments.
The executable program can either be specified with its full path or
with the name of the executable only. If no full path is provided the
executable is looked up in the $PATH used by the desktop environment.
The name or path of the executable program may not contain the equal
sign ("="). Arguments are separated by a space.
</p><p>
Arguments may be quoted in whole. If an argument contains a reserved
character the argument must be quoted. The rules for quoting of
arguments is also applicable to the executable name or path of the
executable program as provided.
</p><p>
Quoting must be done by enclosing the argument between double quotes
and escaping the double quote character, backtick character ("`"),
dollar sign ("$") and backslash character ("\") by preceding it with an
additional backslash character. Implementations must undo quoting before
expanding field codes and before passing the argument to the executable
program. Reserved characters are space (" "), tab, newline, double
quote, single quote ("'"), backslash character ("\"),
greater-than sign (">"), less-than sign ("<"),
tilde ("~"), vertical bar ("|"), ampersand ("&"), semicolon (";"),
dollar sign ("$"), asterisk ("*"), question mark ("?"), hash mark ("#"),
parenthesis ("(") and (")") and backtick character ("`").
</p><p>
Note that the general escape rule for values of type string states that
the backslash character can be escaped as ("\\") as well and that this
escape rule is applied before the quoting rule. As such, to
unambiguously represent a literal backslash character in a quoted
argument in a desktop entry file requires the use of four successive
backslash characters ("\\\\"). Likewise, a literal dollar sign in a
quoted argument in a desktop entry file is unambiguously represented
with ("\\$").
</p><p>
A number of special field codes have been defined which will be
expanded by the file manager or program launcher when encountered
in the command line.
Field codes consist of the percentage character ("%") followed by
an alpha character. Literal percentage characters must be escaped
as <code class="literal">%%</code>.
Deprecated field codes should be removed from the command line and
ignored.
Field codes are expanded only once, the string that is used to
replace the field code should not be checked for field codes itself.
</p><p>
Command lines that contain a field code that is not listed in this
specification are invalid and must not be processed, in particular
implementations may not introduce support for field codes not listed
in this specification. Extensions, if any, should be introduced by
means of a new key.
</p><p>
Implementations must take care not to expand field codes into multiple
arguments unless explicitly instructed by this specification.
This means that name fields, filenames and other replacements that
can contain spaces must be passed as a single argument
to the executable program after expansion.
</p><p>
Although the <code class="varname">Exec</code> key is defined to have a value
of the type string, which is limited to ASCII characters, field code
expansion may introduce non-ASCII characters in arguments.
Implementations must take care that all characters in arguments
passed to the executable program are properly encoded according to
the applicable locale setting.
</p><p>
Recognized field codes are as follows:
</p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><thead><tr><th>Code</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">%f</code></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 <code class="literal">%f</code> will be expanded to point at the temporary
         file. Used for programs that do not understand the URL syntax.
         </td></tr><tr><td><code class="literal">%F</code></td><td>
         A list of files. Use for apps that can open several local
         files at once.
         Each file is passed as a separate argument to
         the executable program.
         </td></tr><tr><td><code class="literal">%u</code></td><td>
         A single URL. Local files may either be passed as
         file: URLs or as file path.
         </td></tr><tr><td><code class="literal">%U</code></td><td>
         A list of URLs.
         Each URL is passed as a separate argument to
         the executable program. Local files may either be passed as
         file: URLs or as file path.
         </td></tr><tr><td><code class="literal">%d</code></td><td>
         Deprecated.
         </td></tr><tr><td><code class="literal">%D</code></td><td>
         Deprecated.
         </td></tr><tr><td><code class="literal">%n</code></td><td>
         Deprecated.
         </td></tr><tr><td><code class="literal">%N</code></td><td>
         Deprecated.
         </td></tr><tr><td><code class="literal">%i</code></td><td>
The <code class="varname">Icon</code> key of the desktop entry
expanded as two arguments, first
<code class="literal">--icon</code> and then the value of the
<code class="varname">Icon</code> key. Should not expand to any
arguments if the <code class="varname">Icon</code> key is empty
or missing.
         </td></tr><tr><td><code class="literal">%c</code></td><td>
         The translated name of the application as listed in
         the appropriate <code class="varname">Name</code> key in the
         desktop entry.
         </td></tr><tr><td><code class="literal">%k</code></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><code class="literal">%v</code></td><td>
         Deprecated.
         </td></tr><tr><td><code class="literal">%m</code></td><td>
         Deprecated.
         </td></tr></tbody></table></div><p>
A command line may contain at most one %f, %u, %F or %U field code.
Implementations may assume the presence of a %f field code if none of
these field codes is included. If the application should not open any
file the %f, %u, %F and %U field codes must be removed from the
command line and ignored.
</p><p>
Field codes must not be used inside a quoted argument, the result of
field code expansion inside a quoted argument is undefined. The %F and
%U field codes may only be used as an argument on their own.
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s05.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ar01s07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Recognized desktop entry keys </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Registering MIME Types</td></tr></table></div></body></html>