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.

This entry was posted in tools and tagged , , , . Bookmark the permalink.

7 Responses to Using D-Bus Introspection

  1. pclouds says:

    I’m looking for such an article. Thanks alot :)

  2. Pingback: daveg :: weblog » Blog Archive » Rhythmbox from the command line

  3. JItender Singh says:

    This article had ended my problems, Now I can start working on DBus

  4. vg says:

    Cool, but can i somehow find out what objects are exported by say org.kde.plasma ?

  5. pp says:

    Nice, just what I was looking for

  6. Pingback: Patching Pidgin: itch-scratching with Pidgin's D-Bus API - Tom Lee

  7. Pingback: certmonger D-Bus introspection | Frustrations

Leave a comment