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>
25 <arg choice="plain">--xml</arg>
28 <command>gdbus</command>
29 <arg choice="plain">monitor</arg>
31 <arg choice="plain">--system</arg>
32 <arg choice="plain">--session</arg>
33 <arg choice="plain">--address <replaceable>address</replaceable></arg>
35 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
37 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
41 <command>gdbus</command>
42 <arg choice="plain">call</arg>
44 <arg choice="plain">--system</arg>
45 <arg choice="plain">--session</arg>
46 <arg choice="plain">--address <replaceable>address</replaceable></arg>
48 <arg choice="plain">--dest <replaceable>bus_name</replaceable></arg>
49 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
50 <arg choice="plain">--method <replaceable>org.project.InterfaceName.MethodName</replaceable></arg>
52 <arg choice="plain">--timeout <replaceable>seconds</replaceable></arg>
54 <arg choice="plain">ARG1</arg>
55 <arg choice="plain" rep="repeat">ARG2</arg>
58 <command>gdbus</command>
59 <arg choice="plain">emit</arg>
61 <arg choice="plain">--system</arg>
62 <arg choice="plain">--session</arg>
63 <arg choice="plain">--address <replaceable>address</replaceable></arg>
65 <arg choice="plain">--object-path <replaceable>/path/to/object</replaceable></arg>
66 <arg choice="plain">--signal <replaceable>org.project.InterfaceName.SignalName</replaceable></arg>
68 <arg choice="plain">--dest <replaceable>unique_bus_name</replaceable></arg>
70 <arg choice="plain">ARG1</arg>
71 <arg choice="plain" rep="repeat">ARG2</arg>
74 <command>gdbus</command>
75 <arg choice="plain">help</arg>
80 <title>Description</title>
82 <command>gdbus</command> is a simple tool for working with D-Bus objects.
85 <title>Commands</title>
88 <term><option>introspect</option></term>
90 Prints out interfaces and property values for a remote object.
91 For this to work, the owner of the object needs to implement the
92 <literal>org.freedesktop.DBus.Introspectable</literal> interface.
96 <term><option>monitor</option></term>
98 Monitors one or all objects owned by the owner of
99 <replaceable>bus_name</replaceable>.
103 <term><option>call</option></term>
105 Invokes a method on a remote object. Each argument to pass to the
106 method must be specified as a serialized
107 <link linkend="GVariant"><type>GVariant</type></link> except that strings do
108 not need explicit quotes. The return values are printed out as
109 serialized <link linkend="GVariant"><type>GVariant</type></link>
114 <term><option>emit</option></term>
116 Emits a signal. Each argument to include in the signal must be specified as a serialized
117 <link linkend="GVariant"><type>GVariant</type></link> except that strings do
118 not need explicit quotes.
122 <term><option>help</option></term>
124 Prints help and exit.
132 <title>Bash Completion</title>
134 <command>gdbus</command> ships with a bash completion script to
135 complete commands, destinations, bus names, object paths and
136 interface/method names.
141 <title>Examples</title>
142 This shows how to introspect an object - note that the value of each
143 property is displayed:
145 $ gdbus introspect --system \
146 --dest org.freedesktop.NetworkManager \
147 --object-path /org/freedesktop/NetworkManager/Devices/0
148 node /org/freedesktop/NetworkManager/Devices/0 {
149 interface org.freedesktop.DBus.Introspectable {
151 Introspect(out s data);
153 interface org.freedesktop.DBus.Properties {
161 GetAll(in s interface,
164 interface org.freedesktop.NetworkManager.Device.Wired {
166 PropertiesChanged(a{sv} arg_0);
168 readonly b Carrier = false;
169 readonly u Speed = 0;
170 readonly s HwAddress = '00:1D:72:88:BE:97';
172 interface org.freedesktop.NetworkManager.Device {
176 StateChanged(u arg_0,
180 readonly u DeviceType = 1;
181 readonly b Managed = true;
182 readwrite o Ip6Config = '/';
183 readwrite o Dhcp4Config = '/';
184 readwrite o Ip4Config = '/';
185 readonly u State = 2;
186 readwrite u Ip4Address = 0;
187 readonly u Capabilities = 3;
188 readonly s Driver = 'e1000e';
189 readwrite s Interface = 'eth0';
190 readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
195 In a similar fashion, the <option>introspect</option> command can be
196 used to learn details about the <literal>Notify</literal> method:
200 interface org.freedesktop.Notifications {
202 GetServerInformation(out s return_name,
204 out s return_version,
205 out s return_spec_version);
206 GetCapabilities(out as return_caps);
207 CloseNotification(in u id);
208 Notify(in s app_name,
221 With this information, it's easy to use the <option>call</option>
222 command to display a notification
225 $ gdbus call --session \
226 --dest org.freedesktop.Notifications \
227 --object-path /org/freedesktop/Notifications \
228 --method org.freedesktop.Notifications.Notify \
233 "Here's the body of the notification" \
240 Monitoring all objects on a service:
243 $ gdbus monitor --system --dest org.freedesktop.ConsoleKit
244 Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
245 The name org.freedesktop.ConsoleKit is owned by :1.15
246 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
247 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
248 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
249 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
252 Monitoring a single object on a service:
255 $ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
256 Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
257 The name org.freedesktop.NetworkManager is owned by :1.5
258 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5c>},)
259 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
260 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5e>},)
261 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
268 $ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
272 Emitting a signal to a specific process:
275 $ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
281 <title>AUTHOR</title>
283 Written by David Zeuthen <email>zeuthen@gmail.com</email> with
284 a lot of help from many others.
291 Please send bug reports to either the distribution bug tracker
292 or the upstream bug tracker at
293 <ulink url="https://bugzilla.gnome.org/enter_bug.cgi?product=glib"/>.
298 <title>SEE ALSO</title>
301 <refentrytitle>dbus-send</refentrytitle><manvolnum>1</manvolnum>