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.

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

6 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s