View Single Post
Old 09-05-2019, 03:48 PM   #23
Lucas Malor
Pain in the arse
Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.Lucas Malor will give the Devil his due.
 
Lucas Malor's Avatar
 
Posts: 758
Karma: 77856
Join Date: Apr 2013
Device: Kobo Aura One, Kindle 4
I continue to think it's not difficult. You have simply to check if the device is in sleeping mode, and if it continues to be in that state for more than 1 day, you do shutdown, poweroff or every other command that Kobo ships. This will work if Kobo does not send STOP signal to all background tasks when it goes in sleep mode (I don't think so). It's basically something like this:

Code:
start_time=$(date +%s)

while true; do
    sleep 3 # or whatever you want. 10? Write 10

    # there should be a way to check if the device is in sleeping mode
    device_is_sleeping=boh 

    if [ $device_is_sleeping -eq 0 ] ; then
        start_time=$(date +%s)
    else
        current_time=$(date +%s)
        elapsed_time = $(echo "$current_time - $start_time | bc)

        if [ $elapsed_time -ge 86400 ] ; then
            poweroff
        fi
    fi
done
I remember there's a way to check if Kobo is in sleeping mode. Probably `nickel` process is in stopped state, but also other third party programs stops nickel.

Alternatively, there's /etc/pm/sleep.d . If Kobo has this folder and it works, you can follow this SO answer.

Last edited by Lucas Malor; 09-05-2019 at 04:07 PM.
Lucas Malor is offline   Reply With Quote