3 A simpe client for an onoff device. If no parameters are given, the device
4 is activated for 10 seconds. When a command is given, the device is activated,
5 then the command is run. 10 seconds after the command finishes, the device is
13 from dbus.mainloop.glib import DBusGMainLoop
14 from gi.repository import GObject
16 from onoff.common import ST_ACTIVE
18 def wait_for_signal(proxy, signal):
19 loop = GObject.MainLoop()
24 proxy.connect_to_signal(signal, callback)
29 DBusGMainLoop(set_as_default=True)
30 bus = dbus.SessionBus()
31 proxy = bus.get_object("de.subdivi.onoff0", "/de/subdivi/onoff0/redshift")
33 st, fd = proxy.activatefd(10)
38 print("state is %d waiting for signal" % st)
39 st = wait_for_signal(proxy, "changestate")
40 print("new state is %d" % st)
41 os.execvp(sys.argv[1], sys.argv[1:])
43 st = proxy.activatetime(10)
45 print("state is %d waiting for signal" % st)
46 st = wait_for_signal(proxy, "changestate")
47 print("new state is %d" % st)
49 if __name__ == "__main__":