Demonstrate the idle event & attach event.
[screen-lua.git] / src / scripts / blanker.lua
blob28105d94a1a7bc5b3cf7d84cb0b81262a5183744
1 lock = 0
3 function blank_and_lock (display)
4 if lock == 1 then
5 display.idle_timeout = 10
6 --lockscreen will kill current display...
7 screen.command("lockscreen")
8 lock = 0
9 else
10 lock = 1
11 display.idle_timeout = 2
12 screen.command("blanker")
13 end
14 return 1
15 end
17 function reg_blanker(display)
18 screen.hook(display, "onidle", blank_and_lock)
19 display.idle_timeout = 10
20 end
22 screen.hook("onattach", reg_blanker)
23 reg_blanker(screen.display())