1 <refentry id="gdbus" lang="en">
4 <refentrytitle>gdbus</refentrytitle>
5 <manvolnum>1</manvolnum>
6 <refmiscinfo class="manual">User Commands</refmiscinfo>
10 <refname>gdbus</refname>
11 <refpurpose>Tool for working with D-Bus objects</refpurpose>
16 <command>gdbus</command>
17 <arg choice="plain">introspect</arg>
19 <arg choice="plain">--system</arg>
20 <arg choice="plain">--session</arg>
21 <arg choice="plain">--address <replaceable>address</replaceable></arg>
23 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
24 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
26 <arg choice="plain">--xml</arg>
29 <arg choice="plain">--recurse</arg>
32 <arg choice="plain">--only-properties</arg>
36 <command>gdbus</command>
37 <arg choice="plain">monitor</arg>
39 <arg choice="plain">--system</arg>
40 <arg choice="plain">--session</arg>
41 <arg choice="plain">--address <replaceable>address</replaceable></arg>
43 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
45 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
49 <command>gdbus</command>
50 <arg choice="plain">call</arg>
52 <arg choice="plain">--system</arg>
53 <arg choice="plain">--session</arg>
54 <arg choice="plain">--address <replaceable>address</replaceable></arg>
56 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
57 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
58 <arg choice="plain">--method <replaceable>org.project.InterfaceName.MethodName</replaceable></arg>
60 <arg choice="plain">--timeout <replaceable>seconds</replaceable></arg>
62 <arg choice="plain">ARG1</arg>
63 <arg choice="plain" rep="repeat">ARG2</arg>
66 <command>gdbus</command>
67 <arg choice="plain">emit</arg>
69 <arg choice="plain">--system</arg>
70 <arg choice="plain">--session</arg>
71 <arg choice="plain">--address <replaceable>address</replaceable></arg>
73 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
74 <arg choice="plain">--signal <replaceable>org.project.InterfaceName.SignalName</replaceable></arg>
76 <arg choice="plain">--dest <replaceable>unique_bus_name</replaceable></arg>
78 <arg choice="plain">ARG1</arg>
79 <arg choice="plain" rep="repeat">ARG2</arg>
82 <command>gdbus</command>
83 <arg choice="plain">help</arg>
88 <title>Description</title>
90 <command>gdbus</command> is a simple tool for working with D-Bus objects.
93 <title>Commands</title>
96 <term><option>introspect</option></term>
98 Prints out interfaces and property values for a remote object.
99 For this to work, the owner of the object needs to implement the
100 <literal>org.freedesktop.DBus.Introspectable</literal> interface.
101 If the <option>--xml</option> option is used, the returned
102 introspection XML is printed, otherwise a parsed pretty
103 representation is printed.
104 The <option>--recurse</option> option can be used to
105 introspect children (and their children and so on) and the
106 <option>--only-properties</option> option can be used to
107 only print the interfaces with properties.
111 <term><option>monitor</option></term>
113 Monitors one or all objects owned by the owner of
114 <replaceable>bus_name</replaceable>.
118 <term><option>call</option></term>
120 Invokes a method on a remote object. Each argument to pass to the
121 method must be specified as a serialized
122 <link linkend="GVariant"><type>GVariant</type></link> except that strings do
123 not need explicit quotes. The return values are printed out as
124 serialized <link linkend="GVariant"><type>GVariant</type></link>
129 <term><option>emit</option></term>
131 Emits a signal. Each argument to include in the signal must be specified as a serialized
132 <link linkend="GVariant"><type>GVariant</type></link> except that strings do
133 not need explicit quotes.
137 <term><option>help</option></term>
139 Prints help and exit.
147 <title>Bash Completion</title>
149 <command>gdbus</command> ships with a bash completion script to
150 complete commands, destinations, bus names, object paths and
151 interface/method names.
156 <title>Examples</title>
157 This shows how to introspect an object - note that the value of each
158 property is displayed:
160 $ gdbus introspect --system \
161 --dest org.freedesktop.NetworkManager \
162 --object-path /org/freedesktop/NetworkManager/Devices/0
163 node /org/freedesktop/NetworkManager/Devices/0 {
164 interface org.freedesktop.DBus.Introspectable {
166 Introspect(out s data);
168 interface org.freedesktop.DBus.Properties {
176 GetAll(in s interface,
179 interface org.freedesktop.NetworkManager.Device.Wired {
181 PropertiesChanged(a{sv} arg_0);
183 readonly b Carrier = false;
184 readonly u Speed = 0;
185 readonly s HwAddress = '00:1D:72:88:BE:97';
187 interface org.freedesktop.NetworkManager.Device {
191 StateChanged(u arg_0,
195 readonly u DeviceType = 1;
196 readonly b Managed = true;
197 readwrite o Ip6Config = '/';
198 readwrite o Dhcp4Config = '/';
199 readwrite o Ip4Config = '/';
200 readonly u State = 2;
201 readwrite u Ip4Address = 0;
202 readonly u Capabilities = 3;
203 readonly s Driver = 'e1000e';
204 readwrite s Interface = 'eth0';
205 readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
210 The <option>--recurse</option> and <option>--only-properties</option> options can be useful when wanting to inspect all objects owned by a particular process:
213 $ gdbus introspect --system --dest org.freedesktop.UPower --object-path / --recurse --only-properties
216 node /org/freedesktop {
217 node /org/freedesktop/UPower {
218 interface org.freedesktop.UPower {
220 readonly b IsDocked = true;
221 readonly b LidForceSleep = false;
222 readonly b LidIsPresent = false;
223 readonly b LidIsClosed = false;
224 readonly b OnLowBattery = false;
225 readonly b OnBattery = false;
226 readonly b CanHibernate = true;
227 readonly b CanSuspend = true;
228 readonly s DaemonVersion = '0.9.10';
230 node /org/freedesktop/UPower/Policy {
232 node /org/freedesktop/UPower/Wakeups {
233 interface org.freedesktop.UPower.Wakeups {
235 readonly b HasCapability = true;
244 In a similar fashion, the <option>introspect</option> command can be
245 used to learn details about the <literal>Notify</literal> method:
249 interface org.freedesktop.Notifications {
251 GetServerInformation(out s return_name,
253 out s return_version,
254 out s return_spec_version);
255 GetCapabilities(out as return_caps);
256 CloseNotification(in u id);
257 Notify(in s app_name,
270 With this information, it's easy to use the <option>call</option>
271 command to display a notification
274 $ gdbus call --session \
275 --dest org.freedesktop.Notifications \
276 --object-path /org/freedesktop/Notifications \
277 --method org.freedesktop.Notifications.Notify \
282 "Here's the body of the notification" \
289 Monitoring all objects on a service:
292 $ gdbus monitor --system --dest org.freedesktop.ConsoleKit
293 Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
294 The name org.freedesktop.ConsoleKit is owned by :1.15
295 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
296 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
297 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
298 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
301 Monitoring a single object on a service:
304 $ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
305 Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
306 The name org.freedesktop.NetworkManager is owned by :1.5
307 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5c>},)
308 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
309 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5e>},)
310 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
317 $ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
321 Emitting a signal to a specific process:
324 $ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
330 <title>AUTHOR</title>
332 Written by David Zeuthen <email>zeuthen@gmail.com</email> with
333 a lot of help from many others.
340 Please send bug reports to either the distribution bug tracker
341 or the upstream bug tracker at
342 <ulink url="https://bugzilla.gnome.org/enter_bug.cgi?product=glib"/>.
347 <title>SEE ALSO</title>
350 <refentrytitle>dbus-send</refentrytitle><manvolnum>1</manvolnum>