Blame docs/reference/gio/html/gdbus.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>gdbus: GIO Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GIO Reference Manual">
Packit ae235b
<link rel="up" href="tools.html" title="GIO Tools">
Packit ae235b
<link rel="prev" href="glib-compile-resources.html" title="glib-compile-resources">
Packit ae235b
<link rel="next" href="gdbus-codegen.html" title="gdbus-codegen">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

gdbus

Packit ae235b

gdbus — Tool for working with D-Bus objects

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Synopsis

Packit ae235b

gdbus introspect [ --system | --session | --address address ] --dest bus_name --object-path /path/to/object [ --xml ] [ --recurse ] [ --only-properties ]

Packit ae235b

gdbus monitor [ --system | --session | --address address ] --dest bus_name [ --object-path /path/to/object ]

Packit ae235b

gdbus call [ --system | --session | --address address ] --dest bus_name --object-path /path/to/object --method org.project.InterfaceName.MethodName [ --timeout seconds ] ARG1 ARG2...

Packit ae235b

gdbus emit [ --system | --session | --address address ] --object-path /path/to/object --signal org.project.InterfaceName.SignalName [ --dest unique_bus_name ] ARG1 ARG2...

Packit ae235b

gdbus wait [ --system | --session | --address address ] --activate bus_name [ --timeout seconds ] bus_name

Packit ae235b

gdbus help

Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

Packit ae235b
    gdbus is a simple tool for working with D-Bus objects.
Packit ae235b
  

Packit ae235b
Packit ae235b
Packit ae235b

Commands

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

introspect

Packit ae235b

Packit ae235b
          Prints out interfaces and property values for a remote object.
Packit ae235b
          For this to work, the owner of the object needs to implement the
Packit ae235b
          org.freedesktop.DBus.Introspectable interface.
Packit ae235b
          If the --xml option is used, the returned
Packit ae235b
          introspection XML is printed, otherwise a parsed pretty
Packit ae235b
          representation is printed.
Packit ae235b
          The --recurse option can be used to
Packit ae235b
          introspect children (and their children and so on) and the
Packit ae235b
          --only-properties option can be used to
Packit ae235b
          only print the interfaces with properties.
Packit ae235b
          

Packit ae235b
Packit ae235b
Packit ae235b

monitor

Packit ae235b

Packit ae235b
          Monitors one or all objects owned by the owner of
Packit ae235b
          bus_name.
Packit ae235b
        

Packit ae235b
Packit ae235b
Packit ae235b

call

Packit ae235b

Packit ae235b
          Invokes a method on a remote object.  Each argument to pass to the
Packit ae235b
          method must be specified as a serialized
Packit ae235b
          GVariant except that strings do
Packit ae235b
          not need explicit quotes. The return values are printed out as
Packit ae235b
          serialized GVariant
Packit ae235b
          values.
Packit ae235b
        

Packit ae235b
Packit ae235b
Packit ae235b

emit

Packit ae235b

Packit ae235b
          Emits a signal. Each argument to include in the signal must be specified as a serialized
Packit ae235b
          GVariant except that strings do
Packit ae235b
          not need explicit quotes.
Packit ae235b
        

Packit ae235b
Packit ae235b
Packit ae235b

wait

Packit ae235b

Packit ae235b
          Waits until bus_name is owned by some
Packit ae235b
          process on the bus. If the --activate is specified,
Packit ae235b
          that bus name will be auto-started first. It may be the same as the
Packit ae235b
          bus name being waited for, or different.
Packit ae235b
        

Packit ae235b
Packit ae235b
Packit ae235b

help

Packit ae235b

Packit ae235b
          Prints help and exit.
Packit ae235b
        

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Bash Completion

Packit ae235b

Packit ae235b
    gdbus ships with a bash completion script to
Packit ae235b
    complete commands, destinations, bus names, object paths and
Packit ae235b
    interface/method names.
Packit ae235b
  

Packit ae235b
Packit ae235b
Packit ae235b

Examples

Packit ae235b
  This shows how to introspect an object - note that the value of each
Packit ae235b
  property is displayed:
Packit ae235b
Packit ae235b
$ gdbus introspect --system \
Packit ae235b
        --dest org.freedesktop.NetworkManager \
Packit ae235b
        --object-path /org/freedesktop/NetworkManager/Devices/0
Packit ae235b
node /org/freedesktop/NetworkManager/Devices/0 {
Packit ae235b
  interface org.freedesktop.DBus.Introspectable {
Packit ae235b
    methods:
Packit ae235b
      Introspect(out s data);
Packit ae235b
  };
Packit ae235b
  interface org.freedesktop.DBus.Properties {
Packit ae235b
    methods:
Packit ae235b
      Get(in  s interface,
Packit ae235b
          in  s propname,
Packit ae235b
          out v value);
Packit ae235b
      Set(in  s interface,
Packit ae235b
          in  s propname,
Packit ae235b
          in  v value);
Packit ae235b
      GetAll(in  s interface,
Packit ae235b
             out a{sv} props);
Packit ae235b
  };
Packit ae235b
  interface org.freedesktop.NetworkManager.Device.Wired {
Packit ae235b
    signals:
Packit ae235b
      PropertiesChanged(a{sv} arg_0);
Packit ae235b
    properties:
Packit ae235b
      readonly b Carrier = false;
Packit ae235b
      readonly u Speed = 0;
Packit ae235b
      readonly s HwAddress = '00:1D:72:88:BE:97';
Packit ae235b
  };
Packit ae235b
  interface org.freedesktop.NetworkManager.Device {
Packit ae235b
    methods:
Packit ae235b
      Disconnect();
Packit ae235b
    signals:
Packit ae235b
      StateChanged(u arg_0,
Packit ae235b
                   u arg_1,
Packit ae235b
                   u arg_2);
Packit ae235b
    properties:
Packit ae235b
      readonly u DeviceType = 1;
Packit ae235b
      readonly b Managed = true;
Packit ae235b
      readwrite o Ip6Config = '/';
Packit ae235b
      readwrite o Dhcp4Config = '/';
Packit ae235b
      readwrite o Ip4Config = '/';
Packit ae235b
      readonly u State = 2;
Packit ae235b
      readwrite u Ip4Address = 0;
Packit ae235b
      readonly u Capabilities = 3;
Packit ae235b
      readonly s Driver = 'e1000e';
Packit ae235b
      readwrite s Interface = 'eth0';
Packit ae235b
      readonly s Udi = '/sys/devices/pci0000:00/0000:00:19.0/net/eth0';
Packit ae235b
  };
Packit ae235b
};
Packit ae235b
Packit ae235b

Packit ae235b
  The --recurse and --only-properties options can be useful when wanting to inspect all objects owned by a particular process:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus introspect --system --dest org.freedesktop.UPower --object-path / --recurse  --only-properties 
Packit ae235b
node / {
Packit ae235b
  node /org {
Packit ae235b
    node /org/freedesktop {
Packit ae235b
      node /org/freedesktop/UPower {
Packit ae235b
        interface org.freedesktop.UPower {
Packit ae235b
          properties:
Packit ae235b
            readonly b IsDocked = true;
Packit ae235b
            readonly b LidForceSleep = false;
Packit ae235b
            readonly b LidIsPresent = false;
Packit ae235b
            readonly b LidIsClosed = false;
Packit ae235b
            readonly b OnLowBattery = false;
Packit ae235b
            readonly b OnBattery = false;
Packit ae235b
            readonly b CanHibernate = true;
Packit ae235b
            readonly b CanSuspend = true;
Packit ae235b
            readonly s DaemonVersion = '0.9.10';
Packit ae235b
        };
Packit ae235b
        node /org/freedesktop/UPower/Policy {
Packit ae235b
        };
Packit ae235b
        node /org/freedesktop/UPower/Wakeups {
Packit ae235b
          interface org.freedesktop.UPower.Wakeups {
Packit ae235b
            properties:
Packit ae235b
              readonly b HasCapability = true;
Packit ae235b
          };
Packit ae235b
        };
Packit ae235b
      };
Packit ae235b
    };
Packit ae235b
  };
Packit ae235b
};
Packit ae235b
Packit ae235b

Packit ae235b
  In a similar fashion, the introspect command can be
Packit ae235b
  used to learn details about the Notify method:
Packit ae235b

Packit ae235b
Packit ae235b
[...]
Packit ae235b
  interface org.freedesktop.Notifications {
Packit ae235b
    methods:
Packit ae235b
      GetServerInformation(out s return_name,
Packit ae235b
                           out s return_vendor,
Packit ae235b
                           out s return_version,
Packit ae235b
                           out s return_spec_version);
Packit ae235b
      GetCapabilities(out as return_caps);
Packit ae235b
      CloseNotification(in  u id);
Packit ae235b
      Notify(in  s app_name,
Packit ae235b
             in  u id,
Packit ae235b
             in  s icon,
Packit ae235b
             in  s summary,
Packit ae235b
             in  s body,
Packit ae235b
             in  as actions,
Packit ae235b
             in  a{sv} hints,
Packit ae235b
             in  i timeout,
Packit ae235b
             out u return_id);
Packit ae235b
  };
Packit ae235b
[...]
Packit ae235b
Packit ae235b

Packit ae235b
  With this information, it's easy to use the call
Packit ae235b
  command to display a notification
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus call --session \
Packit ae235b
             --dest org.freedesktop.Notifications \
Packit ae235b
             --object-path /org/freedesktop/Notifications \
Packit ae235b
             --method org.freedesktop.Notifications.Notify \
Packit ae235b
             my_app_name \
Packit ae235b
             42 \
Packit ae235b
             gtk-dialog-info \
Packit ae235b
             "The Summary" \
Packit ae235b
             "Here's the body of the notification" \
Packit ae235b
             [] \
Packit ae235b
             {} \
Packit ae235b
             5000
Packit ae235b
(uint32 12,)
Packit ae235b
Packit ae235b

Packit ae235b
  Monitoring all objects on a service:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus monitor --system --dest org.freedesktop.ConsoleKit
Packit ae235b
Monitoring signals from all objects owned by org.freedesktop.ConsoleKit
Packit ae235b
The name org.freedesktop.ConsoleKit is owned by :1.15
Packit ae235b
/org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (false,)
Packit ae235b
/org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('',)
Packit ae235b
/org/freedesktop/ConsoleKit/Session2: org.freedesktop.ConsoleKit.Session.ActiveChanged (true,)
Packit ae235b
/org/freedesktop/ConsoleKit/Seat1: org.freedesktop.ConsoleKit.Seat.ActiveSessionChanged ('/org/freedesktop/ConsoleKit/Session2',)
Packit ae235b
Packit ae235b

Packit ae235b
  Monitoring a single object on a service:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path /org/freedesktop/NetworkManager/AccessPoint/4141
Packit ae235b
Monitoring signals on object /org/freedesktop/NetworkManager/AccessPoint/4141 owned by org.freedesktop.NetworkManager
Packit ae235b
The name org.freedesktop.NetworkManager is owned by :1.5
Packit ae235b
/org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5c>},)
Packit ae235b
/org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
Packit ae235b
/org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x5e>},)
Packit ae235b
/org/freedesktop/NetworkManager/AccessPoint/4141: org.freedesktop.NetworkManager.AccessPoint.PropertiesChanged ({'Strength': <byte 0x64>},)
Packit ae235b
Packit ae235b

Packit ae235b
  Emitting a signal:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus emit --session --object-path /foo --signal org.bar.Foo "['foo', 'bar', 'baz']"
Packit ae235b
Packit ae235b

Packit ae235b
  Emitting a signal to a specific process:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus emit --session --object-path /bar --signal org.bar.Bar someString --dest :1.42
Packit ae235b
Packit ae235b

Packit ae235b
  Waiting for a well-known name to be owned on the bus; this will
Packit ae235b
  not auto-start the service:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus wait --session org.bar.SomeName
Packit ae235b
Packit ae235b

Packit ae235b
  Auto-starting then waiting for a well-known name to be owned on the bus:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus wait --session --activate org.bar.SomeName
Packit ae235b
Packit ae235b

Packit ae235b
  Auto-starting a different service, then waiting for a well-known name to be
Packit ae235b
  owned on the bus. This is useful in situations where
Packit ae235b
  SomeName is not directly activatable:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus wait --session --activate org.bar.PrerequisiteName org.bar.SomeName
Packit ae235b
Packit ae235b

Packit ae235b
  Waiting for a well-known name and giving up after 30 seconds. By default,
Packit ae235b
  the timeout is disabled; or set --timeout to 0 to disable it:
Packit ae235b

Packit ae235b
Packit ae235b
$ gdbus wait --session --timeout 30 org.bar.SomeName
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Bugs

Packit ae235b

Packit ae235b
    Please send bug reports to either the distribution bug tracker
Packit ae235b
    or the upstream bug tracker at
Packit ae235b
    https://bugzilla.gnome.org/enter_bug.cgi?product=glib.
Packit ae235b
  

Packit ae235b
Packit ae235b
Packit ae235b

See Also

Packit ae235b

Packit ae235b
    dbus-send(1)
Packit ae235b
  

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>