MAN page from openSUSE Leap 15 glib2-tools-2.58.3-lp150.395.1.x86_64.rpm
Section: User Commands (1)
gapplication - D-Bus application launcher
- gapplication help [COMMAND]
- gapplication version
- gapplication list-apps
- gapplication launch APPID
- gapplication launch APPID [FILE...]
- gapplication list-actions APPID
- gapplication action APPID ACTION [PARAMETER]
gapplicationis a commandline implementation of the client-side of theorg.freedesktop.Applicationinterface as specified by the freedesktop.org Desktop Entry Specification.
gapplicationcan be used to start applications that haveDBusActivatableset totruein their.desktopfiles and can be used to send messages to already-running instances of other applications.
It is possible for applications to refer togapplicationin theExecline of their.desktopfile to maintain backwards compatibility with implementations that do not directly supportDBusActivatable.
gapplicationships as part ofGLib.
- Displays a short synopsis of the available commands or provides detailed help on a specific command.
- Prints the GLib version whencegapplicationcame.
- Prints a list of all application IDs that are known to support D-Bus activation. This list is generated by scanning.desktopfiles as per the currentXDG_DATA_DIRS.
launch APPID [FILE...]
- Launches an application.
The first parameter is the application ID in the familiar "reverse DNS" style (eg: 'org.gnome.app') without the.desktopsuffix.
Optionally, if additional parameters are given, they are treated as the names of files to open and may be filenames or URIs. If no files are given then the application is simply activated.
- List the actions declared in the application's.desktopfile. The parameter is the application ID, as above.
action APPID ACTION [PARAMETER]
- Invokes the named action (in the same way as would occur when activating an action specified in the.desktopfile).
The application ID (as above) is the first parameter. The action name follows.
Optionally, following the action name can be one parameter, in GVariant format, given as a single argument. Make sure to use sufficient quoting.
From the commandline
Launching an application:
gapplication launch org.example.fooview
Opening a file with an application:
gapplication launch org.example.fooview ~/file.foo
Opening many files with an application:
gapplication launch org.example.fooview ~/foos/*.foo
Invoking an action on an application:
gapplication action org.example.fooview create
Invoking an action on an application, with an action:
gapplication action org.example.fooview show-item '"item_id_828739"'
From the Exec lines of a .desktop file
The commandline interface ofgapplicationwas designed so that it could be used directly from theExecline of a.desktopfile.
You might want to do this to allow for backwards compatibility with implementations of the specification that do not understand how to do D-Bus activation, without having to install a separate utility program.
Consider the following example:
[Desktop Entry] Version=1.1 Type=Application Name=Foo Viewer DBusActivatable=true MimeType=image/x-foo; Exec=gapplication launch org.example.fooview %F Actions=gallery;create; [Desktop Action gallery] Name=Browse Gallery Exec=gapplication action org.example.fooview gallery [Desktop Action create] Name=Create a new Foo! Exec=gapplication action org.example.fooview create
From a script
If installing an application that supports D-Bus activation you may still want to put a file in/usr/binso that your program can be started from a terminal.
It is possible for this file to be a shell script. The script can handle arguments such as --help and --version directly. It can also parse other command line arguments and convert them to uses ofgapplicationto activate the application, open files, or invoke actions.
Here is a simplified example, as may be installed in/usr/bin/fooview:
#!/bin/sh case "$1" in --help) echo "see 'man fooview' for more information" ;; --version) echo "fooview 1.2" ;; --gallery) gapplication action org.example.fooview gallery ;; --create) gapplication action org.example.fooview create ;; -*) echo "unrecognised commandline argument" exit 1 ;; *) gapplication launch org.example.fooview "$@" ;; esac
m[blue]Desktop Entry Specificationm,gdbus(1),xdg-open(1),desktop-file-validate(1)
- Desktop Entry Specification
- Global commands
- From the commandline
- From the Exec lines of a .desktop file
- From a script
- SEE ALSO
This document was created byman2html,using the manual pages.