1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="tools.html" title="GIO Tools">
9 <link rel="prev" href="glib-compile-resources.html" title="glib-compile-resources">
10 <link rel="next" href="gdbus-codegen.html" title="gdbus-codegen">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="glib-compile-resources.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="tools.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">GIO Reference Manual</th>
20 <td><a accesskey="n" href="gdbus-codegen.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 <div lang="en" class="refentry">
23 <a name="gdbus"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
26 <h2><span class="refentrytitle">gdbus</span></h2>
27 <p>gdbus — Tool for working with D-Bus objects</p>
29 <td valign="top" align="right"></td>
31 <div class="refsynopsisdiv">
33 <div class="cmdsynopsis"><p><code class="command">gdbus</code> introspect [ --system | --session | --address <em class="replaceable"><code>address</code></em> ] --dest <em class="replaceable"><code>bus_name</code></em> --object-path <em class="replaceable"><code>/path/to/object</code></em> [ --xml ] [ --recurse ] [ --only-properties ]</p></div>
34 <div class="cmdsynopsis"><p><code class="command">gdbus</code> monitor [ --system | --session | --address <em class="replaceable"><code>address</code></em> ] --dest <em class="replaceable"><code>bus_name</code></em> [ --object-path <em class="replaceable"><code>/path/to/object</code></em> ]</p></div>
35 <div class="cmdsynopsis"><p><code class="command">gdbus</code> call [ --system | --session | --address <em class="replaceable"><code>address</code></em> ] --dest <em class="replaceable"><code>bus_name</code></em> --object-path <em class="replaceable"><code>/path/to/object</code></em> --method <em class="replaceable"><code>org.project.InterfaceName.MethodName</code></em> [ --timeout <em class="replaceable"><code>seconds</code></em> ] ARG1 ARG2... </p></div>
36 <div class="cmdsynopsis"><p><code class="command">gdbus</code> emit [ --system | --session | --address <em class="replaceable"><code>address</code></em> ] --object-path <em class="replaceable"><code>/path/to/object</code></em> --signal <em class="replaceable"><code>org.project.InterfaceName.SignalName</code></em> [ --dest <em class="replaceable"><code>unique_bus_name</code></em> ] ARG1 ARG2... </p></div>
37 <div class="cmdsynopsis"><p><code class="command">gdbus</code> help </p></div>
39 <div class="refsect1">
40 <a name="id543700"></a><h2>Description</h2>
42 <span class="command"><strong>gdbus</strong></span> is a simple tool for working with D-Bus objects.
44 <div class="refsect2">
45 <a name="id884507"></a><h3>Commands</h3>
46 <div class="variablelist"><table border="0">
47 <col align="left" valign="top">
50 <td><p><span class="term"><code class="option">introspect</code></span></p></td>
52 Prints out interfaces and property values for a remote object.
53 For this to work, the owner of the object needs to implement the
54 <code class="literal">org.freedesktop.DBus.Introspectable</code> interface.
55 If the <code class="option">--xml</code> option is used, the returned
56 introspection XML is printed, otherwise a parsed pretty
57 representation is printed.
58 The <code class="option">--recurse</code> option can be used to
59 introspect children (and their children and so on) and the
60 <code class="option">--only-properties</code> option can be used to
61 only print the interfaces with properties.
65 <td><p><span class="term"><code class="option">monitor</code></span></p></td>
67 Monitors one or all objects owned by the owner of
68 <em class="replaceable"><code>bus_name</code></em>.
72 <td><p><span class="term"><code class="option">call</code></span></p></td>
74 Invokes a method on a remote object. Each argument to pass to the
75 method must be specified as a serialized
76 <a href="./../glib/glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> except that strings do
77 not need explicit quotes. The return values are printed out as
78 serialized <a href="./../glib/glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a>
83 <td><p><span class="term"><code class="option">emit</code></span></p></td>
85 Emits a signal. Each argument to include in the signal must be specified as a serialized
86 <a href="./../glib/glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> except that strings do
87 not need explicit quotes.
91 <td><p><span class="term"><code class="option">help</code></span></p></td>
100 <div class="refsect1">
101 <a name="id967616"></a><h2>Bash Completion</h2>
103 <span class="command"><strong>gdbus</strong></span> ships with a bash completion script to
104 complete commands, destinations, bus names, object paths and
105 interface/method names.
108 <div class="refsect1">
109 <a name="id685353"></a><h2>Examples</h2>
110 This shows how to introspect an object - note that the value of each
111 property is displayed:
112 <pre class="programlisting">
113 $ gdbus introspect --system \
114 --dest org.freedesktop.NetworkManager \
115 --object-path /org/freedesktop/NetworkManager/Devices/0
116 node /org/freedesktop/NetworkManager/Devices/0 {
117 interface org.freedesktop.DBus.Introspectable {
119 Introspect(out s data);
121 interface org.freedesktop.DBus.Properties {
129 GetAll(in s interface,
132 interface org.freedesktop.NetworkManager.Device.Wired {
134 PropertiesChanged(a{sv} arg_0);
136 readonly b Carrier = false;
137 readonly u Speed = 0;
138 readonly s HwAddress = '00:1D:72:88:BE:97';
140 interface org.freedesktop.NetworkManager.Device {
144 StateChanged(u arg_0,
148 readonly u DeviceType = 1;
149 readonly b Managed = true;
150 readwrite o Ip6Config = '/';
151 readwrite o Dhcp4Config = '/';
152 readwrite o Ip4Config = '/';
153 readonly u State = 2;
154 readwrite u Ip4Address = 0;
155 readonly u Capabilities = 3;
156 readonly s Driver = 'e1000e';
157 readwrite s Interface = 'eth0';
158 readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
163 The <code class="option">--recurse</code> and <code class="option">--only-properties</code> options can be useful when wanting to inspect all objects owned by a particular process:
165 <pre class="programlisting">
166 $ gdbus introspect --system --dest org.freedesktop.UPower --object-path / --recurse --only-properties
169 node /org/freedesktop {
170 node /org/freedesktop/UPower {
171 interface org.freedesktop.UPower {
173 readonly b IsDocked = true;
174 readonly b LidForceSleep = false;
175 readonly b LidIsPresent = false;
176 readonly b LidIsClosed = false;
177 readonly b OnLowBattery = false;
178 readonly b OnBattery = false;
179 readonly b CanHibernate = true;
180 readonly b CanSuspend = true;
181 readonly s DaemonVersion = '0.9.10';
183 node /org/freedesktop/UPower/Policy {
185 node /org/freedesktop/UPower/Wakeups {
186 interface org.freedesktop.UPower.Wakeups {
188 readonly b HasCapability = true;
197 In a similar fashion, the <code class="option">introspect</code> command can be
198 used to learn details about the <code class="literal">Notify</code> method:
200 <pre class="programlisting">
202 interface org.freedesktop.Notifications {
204 GetServerInformation(out s return_name,
206 out s return_version,
207 out s return_spec_version);
208 GetCapabilities(out as return_caps);
209 CloseNotification(in u id);
210 Notify(in s app_name,
223 With this information, it's easy to use the <code class="option">call</code>
224 command to display a notification
226 <pre class="programlisting">
227 $ gdbus call --session \
228 --dest org.freedesktop.Notifications \
229 --object-path /org/freedesktop/Notifications \
230 --method org.freedesktop.Notifications.Notify \
235 "Here's the body of the notification" \
242 Monitoring all objects on a service:
244 <pre class="programlisting">
245 $ gdbus monitor --system --dest org.freedesktop.ConsoleKit
246 Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
247 The name org.freedesktop.ConsoleKit is owned by :1.15
248 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
249 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
250 /org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
251 /org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
254 Monitoring a single object on a service:
256 <pre class="programlisting">
257 $ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
258 Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
259 The name org.freedesktop.NetworkManager is owned by :1.5
260 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5c>},)
261 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
262 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5e>},)
263 /org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
268 <pre class="programlisting">
269 $ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
272 Emitting a signal to a specific process:
274 <pre class="programlisting">
275 $ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
278 <div class="refsect1">
279 <a name="id983238"></a><h2>AUTHOR</h2>
281 Written by David Zeuthen <code class="email"><<a class="email" href="mailto:zeuthen@gmail.com">zeuthen@gmail.com</a>></code> with
282 a lot of help from many others.
285 <div class="refsect1">
286 <a name="id538698"></a><h2>BUGS</h2>
288 Please send bug reports to either the distribution bug tracker
289 or the upstream bug tracker at
290 <a class="ulink" href="https://bugzilla.gnome.org/enter_bug.cgi?product=glib" target="_top">https://bugzilla.gnome.org/enter_bug.cgi?product=glib</a>.
293 <div class="refsect1">
294 <a name="id607169"></a><h2>SEE ALSO</h2>
296 <span class="citerefentry"><span class="refentrytitle">dbus-send</span>(1)</span>
302 Generated by GTK-Doc V1.18</div>