chiark / gitweb /
busctl: show property values in "introspect" output, add "set-property" command,...
[elogind.git] / man / busctl.xml
index ab18a49d0ad23d0c98a436e3cb0d485cb447935c..e9b758aed50110da97b14ad58ced776d09dea751 100644 (file)
@@ -21,7 +21,8 @@ You should have received a copy of the GNU Lesser General Public License
 along with systemd; If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<refentry id="busctl">
+<refentry id="busctl"
+          xmlns:xi="http://www.w3.org/2001/XInclude">
 
   <refentryinfo>
     <title>busctl</title>
@@ -69,68 +70,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
     <para>The following options are understood:</para>
 
     <variablelist>
-      <varlistentry>
-        <term><option>-h</option></term>
-        <term><option>--help</option></term>
-
-        <listitem><para>Print a short help text and exit.
-        </para></listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>--version</option></term>
-
-        <listitem>
-          <para>Print a short version string and exit.</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>--no-pager</option></term>
-
-        <listitem>
-          <para>Do not pipe output into a pager.</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>--system</option></term>
-
-        <listitem>
-          <para>Talk to the systemd system manager (the
-          default).</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>--user</option></term>
-
-        <listitem>
-          <para>Talk to the systemd manager of the calling
-          user.</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-        <term><option>-H</option></term>
-        <term><option>--host</option></term>
-
-        <listitem>
-          <para>Execute the operation remotely. Specify a hostname, or
-          username and hostname separated by <literal>@</literal>, to
-          connect to. This will use SSH to talk to the remote systemd
-          instance.</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
-          <term><option>-M</option></term>
-          <term><option>--machine=</option></term>
-
-          <listitem><para>Execute the operation on a local container.
-          Specify a container name to connect to.</para></listitem>
-      </varlistentry>
-
       <varlistentry>
           <term><option>--address=<replaceable>ADDRESS</replaceable></option></term>
 
@@ -183,6 +122,64 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
           subset matching <replaceable>MATCH</replaceable>.</para></listitem>
           <!-- TODO: link to sd_bus_add_match when it is written? -->
       </varlistentry>
+
+      <varlistentry>
+        <term><option>--no-legend</option></term>
+
+        <listitem>
+          <para>Do not print the legend,
+          i.e. the column headers and the
+          footer.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>--size=</option></term>
+
+        <listitem>
+          <para>When used with the <command>capture</command> command
+          specifies the maximum bus message size to capture
+          ("snaplen"). Defaults to 4096 bytes.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>--list</option></term>
+
+        <listitem>
+          <para>When used with the <command>tree</command> command shows a
+          flat list of object paths instead of a tree.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><option>--quiet</option></term>
+
+        <listitem>
+          <para>When used with the <command>call</command> command suppresses
+          display of the response message.</para>
+        </listitem>
+      </varlistentry>
+
+
+      <varlistentry>
+        <term><option>--verbose</option></term>
+
+        <listitem>
+          <para>When used with the <command>call</command> or
+          <command>get-property</command> command shows output in a
+          more verbose format.</para>
+        </listitem>
+      </varlistentry>
+
+      <xi:include href="user-system-options.xml" xpointer="user" />
+      <xi:include href="user-system-options.xml" xpointer="system" />
+      <xi:include href="user-system-options.xml" xpointer="host" />
+      <xi:include href="user-system-options.xml" xpointer="machine" />
+
+      <xi:include href="standard-options.xml" xpointer="help" />
+      <xi:include href="standard-options.xml" xpointer="version" />
+      <xi:include href="standard-options.xml" xpointer="no-pager" />
     </variablelist>
   </refsect1>
 
@@ -195,24 +192,88 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
       <varlistentry>
         <term><command>list</command></term>
 
-        <listitem><para>Show endpoints attached to the bus. This is
-        the default if no command is specified.</para></listitem>
+        <listitem><para>Show service names on the bus. This is the
+        default if no command is specified.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><command>status</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg></term>
+
+        <listitem><para>Show process information and credentials of a
+        bus service.</para></listitem>
       </varlistentry>
 
       <varlistentry>
-        <term><command>monitor</command>  <arg choice="opt" rep="repeat"><replaceable>NAME</replaceable></arg></term>
+        <term><command>monitor</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
 
         <listitem><para>Dump messages being exchanged. If
-        <replaceable>NAME</replaceable> is specified, show messages
-        to or from this endpoint. Otherwsise, show all messages on the
-        bus.</para></listitem>
+        <replaceable>SERVICE</replaceable> is specified, show messages
+        to or from this endpoint. Otherwise, show all messages on the
+        bus. Use Ctrl-C to terminate dump.</para></listitem>
       </varlistentry>
 
       <varlistentry>
-        <term><command>status</command>  <arg choice="plain"><replaceable>NAME</replaceable></arg></term>
+        <term><command>capture</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
+
+        <listitem><para>Similar to <command>monitor</command> but
+        writes the output in pcap format (for details see the <ulink
+        url="http://wiki.wireshark.org/Development/LibpcapFileFormat">Libpcap
+        File Format</ulink> description. Make sure to redirect the
+        output to STDOUT to a file. Tools like
+        <citerefentry><refentrytitle>wireshark</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+        may be used to dissect and view the generated
+        files.</para></listitem>
+      </varlistentry>
 
-        <listitem><para>Show process information and credentials of a
-        bus endpoint.</para></listitem>
+      <varlistentry>
+        <term><command>tree</command> <arg choice="opt" rep="repeat"><replaceable>SERVICE</replaceable></arg></term>
+
+        <listitem><para>Shows an object tree of one or more
+        services. If <replaceable>SERVICE</replaceable> is specified,
+        show object tree of the specified services only. Otherwise,
+        show all object trees of all services on the bus that acquired
+        at least one well-known name.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><command>introspect</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg></term>
+
+        <listitem><para>Show interfaces, methods, properties and
+        signals of the specified object (identified by its path) on
+        the specified service.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><command>call</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain"><replaceable>METHOD</replaceable></arg> <arg choice="opt"><replaceable>SIGNATURE</replaceable> <arg choice="opt" rep="repeat"><replaceable>ARGUMENT</replaceable></arg></arg></term>
+
+        <listitem><para>Invoke a method and show the response. Takes a
+        service name, object path, interface name and method name. If
+        parameters shall be passed to the method call a signature
+        string is required, followed by the arguments, individually
+        formatted as strings. For details on the formatting used, see
+        below. To suppress output of the returned data use the
+        <option>--quiet</option> option.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><command>get-property</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain" rep="repeat"><replaceable>PROPERTY</replaceable></arg></term>
+
+        <listitem><para>Retrieve the current value of one or more
+        object properties. Takes a service name, object path,
+        interface name and property name. Multiple properties may be
+        specified at once in which case their values will be shown one
+        after the other, separated by newlines. The output is by
+        default in terse format. Use <option>--verbose</option> for a
+        more elaborate output format.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><command>set-property</command> <arg choice="plain"><replaceable>SERVICE</replaceable></arg> <arg choice="plain"><replaceable>OBJECT</replaceable></arg> <arg choice="plain"><replaceable>INTERFACE</replaceable></arg> <arg choice="plain"><replaceable>PROPERTY</replaceable></arg> <arg choice="plain"><replaceable>SIGNATURE</replaceable></arg> <arg choice="plain" rep="repeat"><replaceable>ARGUMENT</replaceable></arg></term>
+
+        <listitem><para>Set the current value an object
+        property. Takes a service name, object path, interface name,
+        property name, property signature, followed by a list of
+        parameters formatted as strings.</para></listitem>
       </varlistentry>
 
       <varlistentry>
@@ -223,6 +284,118 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
     </variablelist>
   </refsect1>
 
+  <refsect1>
+          <title>Parameter Formatting</title>
+
+          <para>The <command>call</command> and
+          <command>set-property</command> commands take a signature
+          string followed by a list of parameters formatted as string
+          (for details on D-Bus signature strings see the <ulink
+          url="http://dbus.freedesktop.org/doc/dbus-specification.html#type-system">Type
+          system chapter of the D-Bus specification</ulink>). For
+          simple types each parameter following the signature should
+          simply be the parameter's value formatted as
+          string. Positive boolean values may be formatted as
+          <literal>true</literal>, <literal>yes</literal>,
+          <literal>on</literal>, <literal>1</literal>; negative
+          boolean values may be specified as <literal>false</literal>,
+          <literal>no</literal>, <literal>off</literal>,
+          <literal>0</literal>. For arrays, a numeric argument for the
+          number of entries followed by the entries shall be
+          specified. For variants the signature of the contents shall
+          be specified, followed by the contents. For dictionaries and
+          structs the contents of them shall be directly
+          specified.</para>
+
+          <para>For example,
+          <programlisting>s jawoll</programlisting> is the formatting
+          of a single string <literal>jawoll</literal>.</para>
+
+          <para>
+          <programlisting>as 3 hello world foobar</programlisting>
+          is the formatting of a string array with three entries,
+          <literal>hello</literal>, <literal>world</literal> and
+          <literal>foobar</literal>.</para>
+
+          <para>
+          <programlisting>a{sv} 3 One s Eins Two u 2 Yes b true</programlisting>
+          is the formatting of a dictionary
+          array that maps strings to variants, consisting of three
+          entries. The string <literal>One</literal> is assigned the
+          string <literal>Eins</literal>. The string
+          <literal>Two</literal> is assigned the 32bit unsigned
+          integer 2. The string <literal>Yes</literal> is assigned a
+          positive boolean.</para>
+
+          <para>Note that the <command>call</command>,
+          <command>get-property</command>,
+          <command>introspect</command> commands will also generate
+          output in this format for the returned data. Since this
+          format is sometimes too terse to be easily understood, the
+          <command>call</command> and <command>get-property</command>
+          commands may generate a more verbose, multi-line output when
+          passed the <option>--verbose</option> option.</para>
+  </refsect1>
+
+  <refsect1>
+          <title>Examples</title>
+
+          <example>
+                  <title>Write and Read a Property</title>
+
+                  <para>The following two commands first write a
+                  property and then read it back. The property is
+                  found on the
+                  <literal>/org/freedesktop/systemd1</literal> object
+                  of the <literal>org.freedesktop.systemd1</literal>
+                  service. The name of the property is
+                  <literal>LogLevel</literal> on the
+                  <literal>org.freedesktop.systemd1.Manager</literal>
+                  interface. The property contains a single
+                  string:</para>
+
+                  <programlisting># busctl set-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel s debug
+# busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager LogLevel
+s "debug"</programlisting>
+
+          </example>
+
+          <example>
+                  <title>Terse and Verbose Output</title>
+
+                  <para>The following two commands read a property that
+                  contains an array of strings, and first show it in
+                  terse format, followed by verbose format:</para>
+
+                  <programlisting>$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Environment
+as 2 "LANG=en_US.UTF-8" "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
+$ busctl get-property --verbose org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Environment
+ARRAY "s" {
+        STRING "LANG=en_US.UTF-8";
+        STRING "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin";
+};</programlisting>
+          </example>
+
+        <example>
+                  <title>Invoking a Method</title>
+
+                  <para>The following command invokes a the
+                  <literal>StartUnit</literal> method on the
+                  <literal>org.freedesktop.systemd1.Manager</literal>
+                  interface of the
+                  <literal>/org/freedesktop/systemd1</literal> object
+                  of the <literal>org.freedesktop.systemd1</literal>
+                  service, and passes it two strings
+                  <literal>cups.service</literal> and
+                  <literal>replace</literal>. As result of the method
+                  call a single object path parameter is received and
+                  shown:</para>
+
+                  <programlisting># busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager StartUnit ss "cups.service" "replace"
+o "/org/freedesktop/systemd1/job/42684"</programlisting>
+        </example>
+  </refsect1>
+
   <refsect1>
     <title>See Also</title>
 
@@ -233,7 +406,8 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>systemd-bus-proxyd</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
-      <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+      <citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>wireshark</refentrytitle><manvolnum>1</manvolnum></citerefentry>
     </para>
   </refsect1>
 </refentry>