1 <refentry id="gdbus" lang="en">
5 <productname>GIO</productname>
8 <contrib>Developer</contrib>
9 <firstname>David</firstname>
10 <surname>Zeuthen</surname>
11 <email>zeuthen@gmail.com</email>
17 <refentrytitle>gdbus</refentrytitle>
18 <manvolnum>1</manvolnum>
19 <refmiscinfo class="manual">User Commands</refmiscinfo>
23 <refname>gdbus</refname>
24 <refpurpose>Tool for working with D-Bus objects</refpurpose>
29 <command>gdbus</command>
30 <arg choice="plain">introspect</arg>
32 <arg choice="plain">--system</arg>
33 <arg choice="plain">--session</arg>
34 <arg choice="plain">--address <replaceable>address</replaceable></arg>
36 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
37 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
39 <arg choice="plain">--xml</arg>
42 <arg choice="plain">--recurse</arg>
45 <arg choice="plain">--only-properties</arg>
49 <command>gdbus</command>
50 <arg choice="plain">monitor</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>
58 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
62 <command>gdbus</command>
63 <arg choice="plain">call</arg>
65 <arg choice="plain">--system</arg>
66 <arg choice="plain">--session</arg>
67 <arg choice="plain">--address <replaceable>address</replaceable></arg>
69 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
70 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
71 <arg choice="plain">--method <replaceable>org.project.InterfaceName.MethodName</replaceable></arg>
73 <arg choice="plain">--timeout <replaceable>seconds</replaceable></arg>
75 <arg choice="plain">ARG1</arg>
76 <arg choice="plain" rep="repeat">ARG2</arg>
79 <command>gdbus</command>
80 <arg choice="plain">emit</arg>
82 <arg choice="plain">--system</arg>
83 <arg choice="plain">--session</arg>
84 <arg choice="plain">--address <replaceable>address</replaceable></arg>
86 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
87 <arg choice="plain">--signal <replaceable>org.project.InterfaceName.SignalName</replaceable></arg>
89 <arg choice="plain">--dest <replaceable>unique_bus_name</replaceable></arg>
91 <arg choice="plain">ARG1</arg>
92 <arg choice="plain" rep="repeat">ARG2</arg>
95 <command>gdbus</command>
96 <arg choice="plain">help</arg>
101 <title>Description</title>
103 <command>gdbus</command> is a simple tool for working with D-Bus objects.
107 <title>Commands</title>
110 <term><option>introspect</option></term>
112 Prints out interfaces and property values for a remote object.
113 For this to work, the owner of the object needs to implement the
114 <literal>org.freedesktop.DBus.Introspectable</literal> interface.
115 If the <option>--xml</option> option is used, the returned
116 introspection XML is printed, otherwise a parsed pretty
117 representation is printed.
118 The <option>--recurse</option> option can be used to
119 introspect children (and their children and so on) and the
120 <option>--only-properties</option> option can be used to
121 only print the interfaces with properties.
125 <term><option>monitor</option></term>
127 Monitors one or all objects owned by the owner of
128 <replaceable>bus_name</replaceable>.
132 <term><option>call</option></term>
134 Invokes a method on a remote object. Each argument to pass to the
135 method must be specified as a serialized
136 <link linkend="GVariant"><type>GVariant</type></link> except that strings do
137 not need explicit quotes. The return values are printed out as
138 serialized <link linkend="GVariant"><type>GVariant</type></link>
143 <term><option>emit</option></term>
145 Emits a signal. Each argument to include in the signal must be specified as a serialized
146 <link linkend="GVariant"><type>GVariant</type></link> except that strings do
147 not need explicit quotes.
151 <term><option>help</option></term>
153 Prints help and exit.
160 <title>Bash Completion</title>
162 <command>gdbus</command> ships with a bash completion script to
163 complete commands, destinations, bus names, object paths and
164 interface/method names.
169 <title>Examples</title>
170 This shows how to introspect an object - note that the value of each
171 property is displayed:
173 $ gdbus introspect --system \
174 --dest org.freedesktop.NetworkManager \
175 --object-path /org/freedesktop/NetworkManager/Devices/0
176 node /org/freedesktop/NetworkManager/Devices/0 {
177 interface org.freedesktop.DBus.Introspectable {
179 Introspect(out s data);
181 interface org.freedesktop.DBus.Properties {
189 GetAll(in s interface,
192 interface org.freedesktop.NetworkManager.Device.Wired {
194 PropertiesChanged(a{sv} arg_0);
196 readonly b Carrier = false;
197 readonly u Speed = 0;
198 readonly s HwAddress = '00:1D:72:88:BE:97';
200 interface org.freedesktop.NetworkManager.Device {
204 StateChanged(u arg_0,
208 readonly u DeviceType = 1;
209 readonly b Managed = true;
210 readwrite o Ip6Config = '/';
211 readwrite o Dhcp4Config = '/';
212 readwrite o Ip4Config = '/';
213 readonly u State = 2;
214 readwrite u Ip4Address = 0;
215 readonly u Capabilities = 3;
216 readonly s Driver = 'e1000e';
217 readwrite s Interface = 'eth0';
218 readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
223 The <option>--recurse</option> and <option>--only-properties</option> options can be useful when wanting to inspect all objects owned by a particular process:
226 $ gdbus introspect --system --dest org.freedesktop.UPower --object-path / --recurse --only-properties
229 node /org/freedesktop {
230 node /org/freedesktop/UPower {
231 interface org.freedesktop.UPower {
233 readonly b IsDocked = true;
234 readonly b LidForceSleep = false;
235 readonly b LidIsPresent = false;
236 readonly b LidIsClosed = false;
237 readonly b OnLowBattery = false;
238 readonly b OnBattery = false;
239 readonly b CanHibernate = true;
240 readonly b CanSuspend = true;
241 readonly s DaemonVersion = '0.9.10';
243 node /org/freedesktop/UPower/Policy {
245 node /org/freedesktop/UPower/Wakeups {
246 interface org.freedesktop.UPower.Wakeups {
248 readonly b HasCapability = true;
257 In a similar fashion, the <option>introspect</option> command can be
258 used to learn details about the <literal>Notify</literal> method:
262 interface org.freedesktop.Notifications {
264 GetServerInformation(out s return_name,
266 out s return_version,
267 out s return_spec_version);
268 GetCapabilities(out as return_caps);
269 CloseNotification(in u id);
270 Notify(in s app_name,
283 With this information, it's easy to use the <option>call</option>
284 command to display a notification
287 $ gdbus call --session \
288 --dest org.freedesktop.Notifications \
289 --object-path /org/freedesktop/Notifications \
290 --method org.freedesktop.Notifications.Notify \
295 "Here's the body of the notification" \
302 Monitoring all objects on a service:
305 $ gdbus monitor --system --dest org.freedesktop.ConsoleKit
306 Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
307 The name org.freedesktop.ConsoleKit is owned by :1.15
308 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
309 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
310 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
311 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
314 Monitoring a single object on a service:
317 $ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
318 Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
319 The name org.freedesktop.NetworkManager is owned by :1.5
320 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5c>},)
321 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
322 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5e>},)
323 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
330 $ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
334 Emitting a signal to a specific process:
337 $ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
345 Please send bug reports to either the distribution bug tracker
346 or the upstream bug tracker at
347 <ulink url="https://bugzilla.gnome.org/enter_bug.cgi?product=glib"/>.
352 <title>See Also</title>
355 <refentrytitle>dbus-send</refentrytitle><manvolnum>1</manvolnum>