/usr/lib/neard/tools/monitor-near is in neard-tools 0.11-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | #! /usr/bin/python
import gobject
import dbus
import dbus.mainloop.glib
from dbus.lowlevel import MethodCallMessage, HANDLER_RESULT_NOT_YET_HANDLED
def extract_list(list):
val = "["
for i in list:
val += " " + str(i)
val += " ]"
return val
def extract_bool(b):
if b == dbus.Boolean(1):
val = "true"
else:
val = "false"
return val
def property_changed_tag(name, value, path):
tag = path[path.rfind("/") + 1:]
if name in ["Records"]:
val = extract_list(value)
print "[Tag] [%s] %s = %s" % (tag, name, val)
def property_changed_device(name, value, path):
device = path[path.rfind("/") + 1:]
if name in ["Records"]:
val = extract_list(value)
print "[Device] [%s] %s = %s" % (device, name, val)
def property_changed_adapter(name, value, path):
adapter = path[path.rfind("/") + 1:]
if name in ["Polling"]:
val = extract_bool(value)
elif name in ["Tags", "Devices"]:
val = extract_list(value)
else:
val = str(value)
print "[Adapter] [%s] %s = %s" % (adapter, name, val)
def property_changed_manager(name, value, path):
manager = path[path.rfind("/") + 1:]
if name in ["Adapters"]:
val = extract_list(value)
print "[Manager] %s = %s" % (name, val)
if __name__ == '__main__':
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(property_changed_manager,
bus_name="org.neard",
dbus_interface="org.neard.Manager",
signal_name = "PropertyChanged",
path_keyword="path")
bus.add_signal_receiver(property_changed_adapter,
bus_name="org.neard",
dbus_interface="org.neard.Adapter",
signal_name = "PropertyChanged",
path_keyword="path")
bus.add_signal_receiver(property_changed_tag,
bus_name="org.neard",
dbus_interface="org.neard.Tag",
signal_name = "PropertyChanged",
path_keyword="path")
bus.add_signal_receiver(property_changed_device,
bus_name="org.neard",
dbus_interface="org.neard.Device",
signal_name = "PropertyChanged",
path_keyword="path")
mainloop = gobject.MainLoop()
mainloop.run()
|