1#!/usr/bin/python
2
3import gobject
4
5import dbus
6import dbus.mainloop.glib
7
8def element_signal(path, member):
9    if member == "ElementAdded":
10        action = "Add   "
11    elif member == "ElementRemoved":
12        action = "Remove"
13    elif member == "ElementUpdated":
14        action = "Update"
15    else:
16        return
17    print "%s  [ %s ]" % (action, path)
18
19if __name__ == '__main__':
20    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
21
22    bus = dbus.SystemBus()
23
24    bus.add_signal_receiver(element_signal,
25                            bus_name="org.chromium.flimflam",
26                            signal_name = "ElementAdded",
27                            path_keyword="path",
28                            member_keyword="member")
29    bus.add_signal_receiver(element_signal,
30                            bus_name="org.chromium.flimflam",
31                            signal_name = "ElementRemoved",
32                            path_keyword="path",
33                            member_keyword="member")
34    bus.add_signal_receiver(element_signal,
35                            bus_name="org.chromium.flimflam",
36                            signal_name = "ElementUpdated",
37                            path_keyword="path",
38                            member_keyword="member")
39
40    mainloop = gobject.MainLoop()
41    mainloop.run()
42