Using D-Bus Introspection

To control a D-Bus-enabled application, you need the interface definition to find out which methods are offered and which parameters they expect.

Of course, you can get the relevant interface definition from the application's source distribution. But there's an easier way: Ask the object in question via D-Bus to give you the interface description. All objects implementing the org.freedesktop.DBus.Introspectable interface offer an Introspect() method that returns an XML document describing the methods and their signatures.

Instead of python, we'll use the dbus-send command line utility this time. The following command dumps the definition of rhythmbox' /org/gnome/Rhythmbox/Player object:

dbus-send --session --type=method_call --print-reply
    --dest=org.gnome.Rhythmbox
    /org/gnome/Rhythmbox/Player
    org.freedesktop.DBus.Introspectable.Introspect

The service to query is org.gnome.Rhythmbox and the object's interface is org.freedesktop.DBus.Introspectable. Note that for dbus-send, the method's name (Introspect here) has to be appended to the interface. See the dbus-send manpage for more information, like calling methods with parameters.

social