Dbus

From wikinotes


The dbus provides a method of inter-process communication (message passing). User/Services are organized into session-address spaces, programs have addresses within those address spaces, programs contain objects you can interface with to control/retrieve information from them.


Concepts

Address

The purpose of dbus is to share info with, and be controlled by other processes. DBus creates local proxy-objects that you can interact with based on the remote objects.


There are generally 2x dbus sessions that dbus addresses are registered under.

  • SessionBus contains user programs
  • SystemBus contains services
session_bus = pydbus.SessionBus()
system_bus  = pydbus.SystemBus()


Address paths are used to specify which dbus interface you are interacting with

org.freedesktop.DBus
org.freedesktop.Notifications
org.gnome.Rhythmbox

Object paths are paths to the object you want to retrieve from the DBus address you specified. These look like unix paths.

/org/freedesktop/DBus
/org/gnome/Rhythmbox/Player

Get Info


Control

Interfaces

There are tons of interfaces written for many languages to communicate with the dbus. A Few notables:

d-feet								## detailed info about dbus paths, including expected arguments
qdbus (--system|--session)		## lists all running dbus addrs
#### python
import pydbus
session_bus = pydbus.SessionBus()
dbus_obj    = session_bus.get(
						'org.freedesktop.DBus',
						'/org/freedesktop/DBus',
					)
print( dbus_obj.Introspect()[0] )
print( dbus_obj.ListNames()[0]  )
#### dbus-send
dbus-send --session --type=method_call --print-reply \
          --dest=org.freedesktop.DBus \
                /org/freedesktop/DBus \
                 org.freedesktop.DBus.Introspectable.Introspect

## (get all addresses under object)
dbus-send --session --type=method_call --print-reply \
          --dest=org.freedesktop.DBus \
                /org/freedesktop/DBus \
                 org.freedesktop.DBus.ListNames

DBus Browsers

To help navigate the maze of dbus locations, you can checkout browsers that people have written to navigate through them.

d-feet https://wiki.gnome.org/action/show/Apps/DFeet?action=show&redirect=DFeet
Bustle https://www.freedesktop.org/wiki/Software/Bustle/

See Also

http://www.linuxjournal.com/article/10455
https://github.com/LEW21/pydbus/blob/master/README.rst