1GDBUS(1) User Commands GDBUS(1)
2
3
4
6 gdbus - Tool for working with D-Bus objects
7
9 gdbus introspect [--system | --session | --address address]
10 --dest bus_name --object-path /path/to/object [--xml] [--recurse]
11 [--only-properties]
12
13 gdbus monitor [--system | --session | --address address]
14 --dest bus_name [--object-path /path/to/object]
15
16 gdbus call [--system | --session | --address address] --dest bus_name
17 --object-path /path/to/object
18 --method org.project.InterfaceName.MethodName [--timeout seconds]
19 ARG1 ARG2...
20
21 gdbus emit [--system | --session | --address address]
22 --object-path /path/to/object
23 --signal org.project.InterfaceName.SignalName
24 [--dest unique_bus_name] ARG1 ARG2...
25
26 gdbus wait [--system | --session | --address address]
27 --activate bus_name [--timeout seconds] bus_name
28
29 gdbus help
30
32 gdbus is a simple tool for working with D-Bus objects.
33
35 introspect
36 Prints out interfaces and property values for a remote object. For
37 this to work, the owner of the object needs to implement the
38 org.freedesktop.DBus.Introspectable interface. If the --xml option
39 is used, the returned introspection XML is printed, otherwise a
40 parsed pretty representation is printed. The --recurse option can
41 be used to introspect children (and their children and so on) and
42 the --only-properties option can be used to only print the
43 interfaces with properties.
44
45 monitor
46 Monitors one or all objects owned by the owner of bus_name.
47
48 call
49 Invokes a method on a remote object. Each argument to pass to the
50 method must be specified as a serialized GVariant except that
51 strings do not need explicit quotes. The return values are printed
52 out as serialized GVariant values.
53
54 emit
55 Emits a signal. Each argument to include in the signal must be
56 specified as a serialized GVariant except that strings do not need
57 explicit quotes.
58
59 wait
60 Waits until bus_name is owned by some process on the bus. If the
61 --activate is specified, that bus name will be auto-started first.
62 It may be the same as the bus name being waited for, or different.
63
64 help
65 Prints help and exit.
66
68 gdbus ships with a bash completion script to complete commands,
69 destinations, bus names, object paths and interface/method names.
70
72 This shows how to introspect an object - note that the value of each
73 property is displayed:
74
75 $ gdbus introspect --system \
76 --dest org.freedesktop.NetworkManager \
77 --object-path /org/freedesktop/NetworkManager/Devices/0
78 node /org/freedesktop/NetworkManager/Devices/0 {
79 interface org.freedesktop.DBus.Introspectable {
80 methods:
81 Introspect(out s data);
82 };
83 interface org.freedesktop.DBus.Properties {
84 methods:
85 Get(in s interface,
86 in s propname,
87 out v value);
88 Set(in s interface,
89 in s propname,
90 in v value);
91 GetAll(in s interface,
92 out a{sv} props);
93 };
94 interface org.freedesktop.NetworkManager.Device.Wired {
95 signals:
96 PropertiesChanged(a{sv} arg_0);
97 properties:
98 readonly b Carrier = false;
99 readonly u Speed = 0;
100 readonly s HwAddress = '00:1D:72:88:BE:97';
101 };
102 interface org.freedesktop.NetworkManager.Device {
103 methods:
104 Disconnect();
105 signals:
106 StateChanged(u arg_0,
107 u arg_1,
108 u arg_2);
109 properties:
110 readonly u DeviceType = 1;
111 readonly b Managed = true;
112 readwrite o Ip6Config = '/';
113 readwrite o Dhcp4Config = '/';
114 readwrite o Ip4Config = '/';
115 readonly u State = 2;
116 readwrite u Ip4Address = 0;
117 readonly u Capabilities = 3;
118 readonly s Driver = 'e1000e';
119 readwrite s Interface = 'eth0';
120 readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
121 };
122 };
123
124 The --recurse and --only-properties options can be useful when wanting
125 to inspect all objects owned by a particular process:
126
127 $ gdbus introspect --system --dest org.freedesktop.UPower --object-path / --recurse --only-properties
128 node / {
129 node /org {
130 node /org/freedesktop {
131 node /org/freedesktop/UPower {
132 interface org.freedesktop.UPower {
133 properties:
134 readonly b IsDocked = true;
135 readonly b LidForceSleep = false;
136 readonly b LidIsPresent = false;
137 readonly b LidIsClosed = false;
138 readonly b OnLowBattery = false;
139 readonly b OnBattery = false;
140 readonly b CanHibernate = true;
141 readonly b CanSuspend = true;
142 readonly s DaemonVersion = '0.9.10';
143 };
144 node /org/freedesktop/UPower/Policy {
145 };
146 node /org/freedesktop/UPower/Wakeups {
147 interface org.freedesktop.UPower.Wakeups {
148 properties:
149 readonly b HasCapability = true;
150 };
151 };
152 };
153 };
154 };
155 };
156
157 In a similar fashion, the introspect command can be used to learn
158 details about the Notify method:
159
160 [...]
161 interface org.freedesktop.Notifications {
162 methods:
163 GetServerInformation(out s return_name,
164 out s return_vendor,
165 out s return_version,
166 out s return_spec_version);
167 GetCapabilities(out as return_caps);
168 CloseNotification(in u id);
169 Notify(in s app_name,
170 in u id,
171 in s icon,
172 in s summary,
173 in s body,
174 in as actions,
175 in a{sv} hints,
176 in i timeout,
177 out u return_id);
178 };
179 [...]
180
181 With this information, it's easy to use the call command to display a
182 notification
183
184 $ gdbus call --session \
185 --dest org.freedesktop.Notifications \
186 --object-path /org/freedesktop/Notifications \
187 --method org.freedesktop.Notifications.Notify \
188 my_app_name \
189 42 \
190 gtk-dialog-info \
191 "The Summary" \
192 "Here's the body of the notification" \
193 [] \
194 {} \
195 5000
196 (uint32 12,)
197
198 Call a method with file handle argument:
199
200 $ gdbus call --session \
201 --dest org.example.foo \
202 --object-path /org/example/foo \
203 --method SendFDs \
204 1 \
205 10 \
206 10<file.foo
207
208 Monitoring all objects on a service:
209
210 $ gdbus monitor --system --dest org.freedesktop.ConsoleKit
211 Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
212 The name org.freedesktop.ConsoleKit is owned by :1.15
213 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
214 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
215 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
216 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
217
218 Monitoring a single object on a service:
219
220 $ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
221 Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
222 The name org.freedesktop.NetworkManager is owned by :1.5
223 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5c>},)
224 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
225 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5e>},)
226 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
227
228 Emitting a signal:
229
230 $ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
231
232 Emitting a signal to a specific process:
233
234 $ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
235
236 Waiting for a well-known name to be owned on the bus; this will not
237 auto-start the service:
238
239 $ gdbus wait --session org.bar.SomeName
240
241 Auto-starting then waiting for a well-known name to be owned on the
242 bus:
243
244 $ gdbus wait --session --activate org.bar.SomeName
245
246 Auto-starting a different service, then waiting for a well-known name
247 to be owned on the bus. This is useful in situations where SomeName is
248 not directly activatable:
249
250 $ gdbus wait --session --activate org.bar.PrerequisiteName org.bar.SomeName
251
252 Waiting for a well-known name and giving up after 30 seconds. By
253 default, the timeout is disabled; or set --timeout to 0 to disable it:
254
255 $ gdbus wait --session --timeout 30 org.bar.SomeName
256
258 Please send bug reports to either the distribution bug tracker or the
259 upstream bug tracker at https://gitlab.gnome.org/GNOME/glib/issues/new.
260
262 dbus-send(1)
263
264
265
266GIO GDBUS(1)