1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>gapplication: GIO Reference Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="tools.html" title="GIO Tools">
9 <link rel="prev" href="gresource-tool.html" title="gresource">
10 <link rel="next" href="gio.html" title="gio">
11 <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts"></td>
17 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
18 <td><a accesskey="u" href="tools.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="gresource-tool.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="gio.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
22 <div lang="en" class="refentry">
23 <a name="gapplication-tool"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
26 <h2><span class="refentrytitle">gapplication</span></h2>
27 <p>gapplication — D-Bus application launcher</p>
29 <td class="gallery_image" valign="top" align="right"></td>
31 <div class="refsynopsisdiv">
33 <div class="cmdsynopsis"><p><code class="command">gapplication</code> help [<em class="replaceable"><code>COMMAND</code></em>]</p></div>
34 <div class="cmdsynopsis"><p><code class="command">gapplication</code> version </p></div>
35 <div class="cmdsynopsis"><p><code class="command">gapplication</code> list-apps </p></div>
36 <div class="cmdsynopsis"><p><code class="command">gapplication</code> launch <em class="replaceable"><code>APPID</code></em> </p></div>
37 <div class="cmdsynopsis"><p><code class="command">gapplication</code> launch <em class="replaceable"><code>APPID</code></em> [<em class="replaceable"><code>FILE</code></em>...]</p></div>
38 <div class="cmdsynopsis"><p><code class="command">gapplication</code> list-actions <em class="replaceable"><code>APPID</code></em> </p></div>
39 <div class="cmdsynopsis"><p><code class="command">gapplication</code> action <em class="replaceable"><code>APPID</code></em> <em class="replaceable"><code>ACTION</code></em> [<em class="replaceable"><code>PARAMETER</code></em>]</p></div>
41 <div class="refsect1">
42 <a name="id-1.4.26.9.5"></a><h2>Description</h2>
44 <span class="command"><strong>gapplication</strong></span> is a commandline implementation of the client-side of the
45 <code class="interfacename">org.freedesktop.Application</code> interface as specified by the freedesktop.org
46 Desktop Entry Specification.
49 <span class="command"><strong>gapplication</strong></span> can be used to start applications that have
50 <code class="varname">DBusActivatable</code> set to <code class="literal">true</code> in their <code class="filename">.desktop</code>
51 files and can be used to send messages to already-running instances of other applications.
54 It is possible for applications to refer to <span class="command"><strong>gapplication</strong></span> in the <code class="varname">Exec</code>
55 line of their <code class="filename">.desktop</code> file to maintain backwards compatibility
56 with implementations that do not directly support <code class="varname">DBusActivatable</code>.
59 <span class="command"><strong>gapplication</strong></span> ships as part of <span class="application">GLib</span>.
62 <div class="refsect1">
63 <a name="id-1.4.26.9.6"></a><h2>Commands</h2>
64 <div class="refsect2">
65 <a name="id-1.4.26.9.6.2"></a><h3>Global commands</h3>
66 <div class="variablelist"><table border="0" class="variablelist">
68 <col align="left" valign="top">
73 <td><p><span class="term">
74 <span class="command"><strong>help</strong></span>
75 [<em class="replaceable"><code>COMMAND</code></em>]
78 Displays a short synopsis of the available commands or provides detailed help on a specific
83 <td><p><span class="term">
84 <span class="command"><strong>version</strong></span>
87 Prints the GLib version whence <span class="command"><strong>gapplication</strong></span> came.
91 <td><p><span class="term">
92 <span class="command"><strong>list-apps</strong></span>
95 Prints a list of all application IDs that are known to support D-Bus activation. This list is
96 generated by scanning <code class="filename">.desktop</code> files as per the current
97 <code class="envar">XDG_DATA_DIRS</code>.
101 <td><p><span class="term">
102 <span class="command"><strong>launch</strong></span>
103 <em class="replaceable"><code>APPID</code></em>
104 [<em class="replaceable"><code>FILE</code></em>...]
108 Launches an application.
111 The first parameter is the application ID in the familiar "reverse DNS" style (eg:
112 '<code class="literal">org.gnome.app</code>') without the <code class="filename">.desktop</code>
116 Optionally, if additional parameters are given, they are treated as the names of files to open and
117 may be filenames or URIs. If no files are given then the application is simply activated.
122 <td><p><span class="term">
123 <span class="command"><strong>list-actions</strong></span>
124 <em class="replaceable"><code>APPID</code></em>
127 List the actions declared in the application's <code class="filename">.desktop</code>
128 file. The parameter is the application ID, as above.
132 <td><p><span class="term">
133 <span class="command"><strong>action</strong></span>
134 <em class="replaceable"><code>APPID</code></em>
135 <em class="replaceable"><code>ACTION</code></em>
136 [<em class="replaceable"><code>PARAMETER</code></em>]
140 Invokes the named action (in the same way as would occur when activating an action specified in
141 the <code class="filename">.desktop</code> file).
144 The application ID (as above) is the first parameter. The action name follows.
147 Optionally, following the action name can be one parameter, in GVariant format, given as a single
148 argument. Make sure to use sufficient quoting.
156 <div class="refsect1">
157 <a name="id-1.4.26.9.7"></a><h2>Examples</h2>
158 <div class="refsect2">
159 <a name="id-1.4.26.9.7.2"></a><h3>From the commandline</h3>
161 Launching an application:
163 <pre class="programlisting">
164 gapplication launch org.example.fooview
167 Opening a file with an application:
169 <pre class="programlisting">
170 gapplication launch org.example.fooview ~/file.foo
173 Opening many files with an application:
175 <pre class="programlisting">
176 gapplication launch org.example.fooview ~/foos/*.foo
179 Invoking an action on an application:
181 <pre class="programlisting">
182 gapplication action org.example.fooview create
185 Invoking an action on an application, with an action:
187 <pre class="programlisting">
188 gapplication action org.example.fooview show-item '"item_id_828739"'
192 <div class="refsect2">
193 <a name="id-1.4.26.9.7.3"></a><h3>
194 From the <code class="varname">Exec</code> lines of a <code class="filename">.desktop</code> file
197 The commandline interface of <span class="command"><strong>gapplication</strong></span> was designed so that it could be used
198 directly from the <code class="varname">Exec</code> line of a <code class="filename">.desktop</code>
202 You might want to do this to allow for backwards compatibility with implementations of the specification
203 that do not understand how to do D-Bus activation, without having to install a separate utility program.
206 Consider the following example:
208 <pre class="programlisting">
214 MimeType=image/x-foo;
215 Exec=gapplication launch org.example.fooview %F
216 Actions=gallery;create;
218 [Desktop Action gallery]
220 Exec=gapplication action org.example.fooview gallery
222 [Desktop Action create]
223 Name=Create a new Foo!
224 Exec=gapplication action org.example.fooview create
228 <div class="refsect2">
229 <a name="id-1.4.26.9.7.4"></a><h3>From a script</h3>
231 If installing an application that supports D-Bus activation you may still want to put a file in
232 <code class="filename">/usr/bin</code> so that your program can be started from a terminal.
235 It is possible for this file to be a shell script. The script can handle arguments such as --help and
236 --version directly. It can also parse other command line arguments and convert them to uses of
237 <span class="command"><strong>gapplication</strong></span> to activate the application, open files, or invoke actions.
240 Here is a simplified example, as may be installed in <code class="filename">/usr/bin/fooview</code>:
242 <pre class="programlisting">
247 echo "see 'man fooview' for more information"
255 gapplication action org.example.fooview gallery
259 gapplication action org.example.fooview create
263 echo "unrecognised commandline argument"
268 gapplication launch org.example.fooview "$@"
274 <div class="refsect1">
275 <a name="id-1.4.26.9.8"></a><h2>See also</h2>
277 <a class="ulink" href="http://standards.freedesktop.org/desktop-entry-spec/latest/" target="_top">Desktop Entry Specification</a>,
278 <span class="citerefentry"><span class="refentrytitle">gdbus</span>(1)</span>,
279 <span class="citerefentry"><span class="refentrytitle">xdg-open</span>(1)</span>,
280 <span class="citerefentry"><span class="refentrytitle">desktop-file-validate</span>(1)</span>
285 <hr>Generated by GTK-Doc V1.25.1</div>