-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhue_props_dev_chg_notify.py
More file actions
executable file
·31 lines (19 loc) · 1.04 KB
/
hue_props_dev_chg_notify.py
File metadata and controls
executable file
·31 lines (19 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import sys
def prop_chg_notify(address, name):
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
DBusGMainLoop(set_as_default=True)
loop = GLib.MainLoop()
systembus = dbus.SystemBus()
sessionbus = dbus.SessionBus()
properties_proxy = dbus.Interface(systembus.get_object('org.bluez', '/org/bluez/hci0/dev_'+ address), 'org.freedesktop.DBus.Properties')
notification_proxy = dbus.Interface(sessionbus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications'), 'org.freedesktop.Notifications')
def handler(interface, changed_properties, invalidated_properties):
for p in changed_properties:
print("%s : %s" % (p, changed_properties[p]))
notification_proxy.Notify("prop_changed", 0, "", "Props %s changed!" % name, "%s = %s" % (str(p), bool(changed_properties[p])), "", {}, 2000)
properties_proxy.connect_to_signal("PropertiesChanged", handler)
loop.run()
prop_chg_notify(sys.argv[1], sys.argv[2])