From: Guo Rui Date: Tue, 14 Jul 2009 15:56:04 +0000 (+0800) Subject: Demonstrate the idle event & attach event. X-Git-Url: https://repo.or.cz/w/screen-lua.git/commitdiff_plain/93cfed2f2bf163fa6baac76b8b6ef03bf8ff5df1 Demonstrate the idle event & attach event. --- diff --git a/src/scripts/blanker.lua b/src/scripts/blanker.lua new file mode 100644 index 0000000..28105d9 --- /dev/null +++ b/src/scripts/blanker.lua @@ -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())