3 """Usage: python list-system-services.py [--session|--system]
4 List services on the system bus (default) or the session bus."""
11 factory
= dbus
.SystemBus
16 if argv
[1] == '--session':
17 factory
= dbus
.SessionBus
18 elif argv
[1] != 'system':
21 # Get a connection to the system or session bus as appropriate
22 # We're only using blocking calls, so don't actually need a main loop here
25 # Get a reference to the desktop bus' standard object, denoted
26 # by the path /org/freedesktop/DBus.
27 dbus_object
= bus
.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
29 # The object /org/freedesktop/DBus
30 # implements the 'org.freedesktop.DBus' interface
31 dbus_iface
= dbus
.Interface(dbus_object
, 'org.freedesktop.DBus')
33 # One of the member functions in the org.freedesktop.DBus interface
34 # is ListServices(), which provides a list of all the other services
35 # registered on this bus. Call it, and print the list.
36 services
= dbus_object
.ListNames()
38 for service
in services
:
41 if __name__
== '__main__':