Python pydbus

From wikinotes


There are a handful of python modules for interfacing with the dbus, based on the recommendations on pypi, I have decided that pydbus is the way to go.


Make sure read dbus for background information on how the dbus works.


Getting Objects

import pydbus

session_bus = pydbus.SessionBus()	## for user interfaces
system_bus  = pydbus.SystemBus()		## for system/service interfaces

notifications = session_bus.get(
	'org.freedesktop.Notifications'	## bus name
	'/org/freedesktop/Notifications'	## Object Address
	)


## Running Object Methods
## (I use d-feet to browse/find the arguments for each method)
notifications.Notify('test', 0, 'dialog-information', 'hello world!', 'pydbus works', [], {}, 5000)

Info About Objects

import pydbus

session_bus = pydbus.SessionBus()

notifications = session_bus.get(
		'org.freedesktop.Notifications',
		'/org/freedesktop/Notifications'
	)
print( notifications.Introspect()[0]  )	## xml object with info about object
print( notifications.ListNames()[0]'  )	## list methods, signals, etc under object