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 # This could be done by calling bus.list_names(), but here's
26 # more or less what that means:
28 # Get a reference to the desktop bus' standard object, denoted
29 # by the path /org/freedesktop/DBus.
30 dbus_object
= bus
.get_object('org.freedesktop.DBus',
31 '/org/freedesktop/DBus')
33 # The object /org/freedesktop/DBus
34 # implements the 'org.freedesktop.DBus' interface
35 dbus_iface
= dbus
.Interface(dbus_object
, 'org.freedesktop.DBus')
37 # One of the member functions in the org.freedesktop.DBus interface
38 # is ListNames(), which provides a list of all the other services
39 # registered on this bus. Call it, and print the list.
40 services
= dbus_iface
.ListNames()
42 for service
in services
:
45 if __name__
== '__main__':