Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom timeout for gesture to exit screensaver #11598

Open
blue-shovel opened this issue Mar 28, 2024 · 1 comment
Open

Allow custom timeout for gesture to exit screensaver #11598

blue-shovel opened this issue Mar 28, 2024 · 1 comment

Comments

@blue-shovel
Copy link

Kobo Clara HD with Koreader v2024.03.1

When using the 'gesture to exit screensaver' option, it would be nice to be able to specify a timeout for that screen and return the device to sleep if that time is exceeded without intervention.

If the frontlight was on when the device last went to sleep, it's turned on again when the device wakes up and goes to the 'waiting for gesture to exit screensaver' screen. If the power button was pressed inadvertently (because it was in a bag, your pocket, or your kids or your cat came in contact with it), it might sit at that screen with the light on for up to 15 minutes before it goes back to sleep (not sure if that time is universal or device-specific). This eats up the battery unnecessarily.

I'd like to be able to set a custom timeout for that screen. I personally would choose maybe 10 seconds. That's to say, if the button is pressed and the device wakes up (and eg., turns the frontlight on), it will return to sleep if I haven't gotten in with a gesture within 10 seconds.

I'm happy to field any questions. Thanks very much for your support and hard work!!

@Frenzie
Copy link
Member

Frenzie commented Apr 9, 2024

I think it's supposed to do that already after 30 seconds, at least on Kobo.

function Kobo:checkUnexpectedWakeup()
-- Just in case another event like SleepCoverClosed also scheduled a suspend
UIManager:unschedule(self.suspend)
-- The proximity window is rather large, because we're scheduled to run 15 seconds after resuming,
-- so we're already guaranteed to be at least 15s away from the alarm ;).
if self.wakeup_mgr:isWakeupAlarmScheduled() and self.wakeup_mgr:wakeupAction(30) then
-- Assume we want to go back to sleep after running the scheduled action
-- (Kobo:resume will unschedule this on an user-triggered resume).
logger.info("Kobo suspend: scheduled wakeup; the device will go back to sleep in 30s.")
-- We need significant leeway for the poweroff action to send out close events to all requisite widgets,
-- since we don't actually want to suspend behind its back ;).
UIManager:scheduleIn(30, self.suspend, self)
else
-- We've hit an early resume, assume this is unexpected (as we only run if Kobo:resume hasn't already).
logger.dbg("Kobo suspend: checking unexpected wakeup number", self.unexpected_wakeup_count)
if self.unexpected_wakeup_count > 20 then
-- If we've failed to put the device back to sleep over 20 consecutive times, we give up.
-- Broadcast a specific event, so that AutoSuspend can pick up the baton...
local Event = require("ui/event")
UIManager:broadcastEvent(Event:new("UnexpectedWakeupLimit"))
return
end
logger.err("Kobo suspend: putting device back to sleep after", self.unexpected_wakeup_count, "unexpected wakeups.")
self:suspend()
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants