1 <refentry id="gapplication-tool" lang="en">
3 <title>gapplication</title>
4 <productname>GIO</productname>
7 <contrib>Developer</contrib>
8 <firstname>Ryan</firstname>
9 <surname>Lortie</surname>
15 <refentrytitle>gapplication</refentrytitle>
16 <manvolnum>1</manvolnum>
17 <refmiscinfo class="manual">User Commands</refmiscinfo>
21 <refname>gapplication</refname>
22 <refpurpose>D-Bus application launcher</refpurpose>
27 <command>gapplication</command>
28 <arg choice="plain">help</arg>
29 <arg choice="opt"><replaceable>COMMAND</replaceable></arg>
32 <command>gapplication</command>
33 <arg choice="plain">version</arg>
36 <command>gapplication</command>
37 <arg choice="plain">list-apps</arg>
40 <command>gapplication</command>
41 <arg choice="plain">launch</arg>
42 <arg choice="plain"><replaceable>APPID</replaceable></arg>
45 <command>gapplication</command>
46 <arg choice="plain">launch</arg>
47 <arg choice="plain"><replaceable>APPID</replaceable></arg>
48 <arg choice="opt" rep="repeat"><replaceable>FILE</replaceable></arg>
51 <command>gapplication</command>
52 <arg choice="plain">list-actions</arg>
53 <arg choice="plain"><replaceable>APPID</replaceable></arg>
56 <command>gapplication</command>
57 <arg choice="plain">action</arg>
58 <arg choice="plain"><replaceable>APPID</replaceable></arg>
59 <arg choice="plain"><replaceable>ACTION</replaceable></arg>
60 <arg choice="opt"><replaceable>PARAMETER</replaceable></arg>
65 <title>Description</title>
68 <command>gapplication</command> is a commandline implementation of the client-side of the
69 <interfacename>org.freedesktop.Application</interfacename> interface as specified by the freedesktop.org
70 Desktop Entry Specification.
74 <command>gapplication</command> can be used to start applications that have
75 <varname>DBusActivatable</varname> set to <literal>true</literal> in their <filename>.desktop</filename>
76 files and can be used to send messages to already-running instances of other applications.
80 It is possible for applications to refer to <command>gapplication</command> in the <varname>Exec</varname>
81 line of their <filename class='extension'>.desktop</filename> file to maintain backwards compatibility
82 with implementations that do not directly support <varname>DBusActivatable</varname>.
86 <command>gapplication</command> ships as part of <application>GLib</application>.
91 <title>Commands</title>
94 <title>Global commands</title>
99 <command>help</command>
100 <arg choice="opt"><replaceable>COMMAND</replaceable></arg>
104 Displays a short synopsis of the available commands or provides detailed help on a specific
112 <command>version</command>
116 Prints the GLib version whence <command>gapplication</command> came.
123 <command>list-apps</command>
127 Prints a list of all application IDs that are known to support D-Bus activation. This list is
128 generated by scanning <filename class='extension'>.desktop</filename> files as per the current
129 <envar>XDG_DATA_DIRS</envar>.
136 <command>launch</command>
137 <arg choice="plain"><replaceable>APPID</replaceable></arg>
138 <arg choice="opt" rep="repeat"><replaceable>FILE</replaceable></arg>
142 Launches an application.
145 The first parameter is the application ID in the familiar "reverse DNS" style (eg:
146 '<literal>org.gnome.app</literal>') without the <filename class='extension'>.desktop</filename>
150 Optionally, if additional parameters are given, they are treated as the names of files to open and
151 may be filenames or URIs. If no files are given then the application is simply activated.
158 <command>list-actions</command>
159 <arg choice="plain"><replaceable>APPID</replaceable></arg>
163 List the actions declared in the application's <filename class='extension'>.desktop</filename>
164 file. The parameter is the application ID, as above.
171 <command>action</command>
172 <arg choice="plain"><replaceable>APPID</replaceable></arg>
173 <arg choice="plain"><replaceable>ACTION</replaceable></arg>
174 <arg choice="opt"><replaceable>PARAMETER</replaceable></arg>
178 Invokes the named action (in the same way as would occur when activating an action specified in
179 the <filename class='extension'>.desktop</filename> file).
182 The application ID (as above) is the first parameter. The action name follows.
185 Optionally, following the action name can be one parameter, in GVariant format, given as a single
186 argument. Make sure to use sufficient quoting.
196 <title>Examples</title>
199 <title>From the commandline</title>
202 Launching an application:
206 gapplication launch org.example.fooview
210 Opening a file with an application:
214 gapplication launch org.example.fooview ~/file.foo
218 Opening many files with an application:
222 gapplication launch org.example.fooview ~/foos/*.foo
226 Invoking an action on an application:
230 gapplication action org.example.fooview create
234 Invoking an action on an application, with an action:
238 gapplication action org.example.fooview show-item '"item_id_828739"'
244 From the <varname>Exec</varname> lines of a <filename class='extension'>.desktop</filename> file
248 The commandline interface of <command>gapplication</command> was designed so that it could be used
249 directly from the <varname>Exec</varname> line of a <filename class='extension'>.desktop</filename>
254 You might want to do this to allow for backwards compatibility with implementations of the specification
255 that do not understand how to do D-Bus activation, without having to install a separate utility program.
259 Consider the following example:
268 MimeType=image/x-foo;
269 Exec=gapplication launch org.example.fooview %F
270 Actions=gallery;create;
272 [Desktop Action gallery]
274 Exec=gapplication action org.example.fooview gallery
276 [Desktop Action create]
277 Name=Create a new Foo!
278 Exec=gapplication action org.example.fooview create
283 <title>From a script</title>
286 If installing an application that supports D-Bus activation you may still want to put a file in
287 <filename class='directory'>/usr/bin</filename> so that your program can be started from a terminal.
291 It is possible for this file to be a shell script. The script can handle arguments such as --help and
292 --version directly. It can also parse other command line arguments and convert them to uses of
293 <command>gapplication</command> to activate the application, open files, or invoke actions.
297 Here is a simplified example, as may be installed in <filename>/usr/bin/fooview</filename>:
305 echo "see 'man fooview' for more information"
313 gapplication action org.example.fooview gallery
317 gapplication action org.example.fooview create
321 echo "unrecognised commandline argument"
326 gapplication launch org.example.fooview "$@"
334 <title>See also</title>
336 <ulink url='http://standards.freedesktop.org/desktop-entry-spec/latest/'>Desktop Entry Specification</ulink>,
338 <refentrytitle>gdbus</refentrytitle>
339 <manvolnum>1</manvolnum>
342 <refentrytitle>xdg-open</refentrytitle>
343 <manvolnum>1</manvolnum>
346 <refentrytitle>desktop-file-validate</refentrytitle>
347 <manvolnum>1</manvolnum>