View Single Post
Old 04-30-2020, 11:48 AM   #1
KristianR
Member
KristianR began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Feb 2016
Device: none
How to exit a "suspended" script (loop)?

Hi there,

if one is running a script without user interaction (e.g. picture frame, dashboard, weather-display ...) what is the best way to return to the ebook reader application without resetting the device?

Example "picture frame":
Current implementation is to have a "while true" loop that updates the image and then sends the reader to "suspend to ram" via rtcwake (e.g. for half an hour - so essentially the reader is in suspend to ram most of the time). What I noticed is that the reader wakes up from suspend to ram when the power button is pressed. I could use this to trigger the script to exit but I am not sure wether the wake up was due to power button press or just at the scheduled time.

I came up with the following ideas:
  • remember the scheduled wake-up-time, compare to actual-wake-up-time. If it differs by more than say 5s assume wake up was due to press of power button -> exit script, restart nickel etc.
  • Monitor /dev/input/event0 in some way
    Code:
    cat /dev/input/event0 | hexdump
    E.g. pipe to file and evaluate if file is empty or not (Was not able to use output of evtest). If file is not empty -> exit script, restart nickel etc.


Which would be the recommended way to implement this? Any other ideas to implement this - is there a way to detect the reason for wake up (i.e. scheduled time reached or power button)?


To restart nickel could this script be used? https://github.com/koreader/koreader...kobo/nickel.sh

Kind regards
KristianR
KristianR is offline   Reply With Quote