Demonstrate the idle event & attach event.
authorGuo Rui <firemeteor@Adam.(none)>
Tue, 14 Jul 2009 15:56:04 +0000 (14 23:56 +0800)
committerGuo Rui <firemeteor@Adam.(none)>
Tue, 14 Jul 2009 15:56:04 +0000 (14 23:56 +0800)
src/scripts/blanker.lua [new file with mode: 0644]

diff --git a/src/scripts/blanker.lua b/src/scripts/blanker.lua
new file mode 100644 (file)
index 0000000..28105d9
--- /dev/null
@@ -0,0 +1,23 @@
+lock = 0
+
+function blank_and_lock (display)
+  if lock == 1 then
+    display.idle_timeout = 10
+    --lockscreen will kill current display...
+    screen.command("lockscreen")
+    lock = 0
+  else
+    lock = 1
+    display.idle_timeout = 2
+    screen.command("blanker")
+  end
+  return 1
+end
+
+function reg_blanker(display)
+  screen.hook(display, "onidle", blank_and_lock)
+  display.idle_timeout = 10
+end
+
+screen.hook("onattach", reg_blanker)
+reg_blanker(screen.display())