01-21-2024, 10:38 AM | #1 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jan 2024
Device: PocketBook Verse Pro
|
Live UI feedback in a "sleep timer" bash script for PocketBook
Hi,
I am trying to code my very first PocketBook bash script. I wanted a little tool to send the device to "sleep" (which is no real sleep, but a simple reboot) after a certain amount of time (so that I could e.g. listen to audiobooks and the playback would be stopped at some point automatically). This is what I came up with so far: Code:
#!/bin/sh SH_IVTOOL=/mnt/ext1/applications/sh_ivtool.app sleep_time=`$SH_IVTOOL -n "Enter sleep in time in mins (or leave empty to cancel):"` # workaround to strip away trailing "latinime: Loading /ebrmain/share/latinime//EN.dict" string sleep_time=${sleep_time:51} if [ $? -eq 0 ]; then while [[ $sleep_time -ne 0 ]]; do sleep 60 sleep_time=$((sleep_time-1)) done iv2sh reboot fi exit 0 I tried to do something like this in the loop, but it did not seem to work stably: Code:
while [[ $sleep_time -ne 0 ]]; do $SH_IVTOOL -s "Will go to sleep in $sleep_time mins $pid" & pid=$! sleep 2 # 2 seconds for testing purposes iv2sh SendEventTo -9 "$pid" sleep_time=$((sleep_time-1)) done Last edited by flx; 01-21-2024 at 10:41 AM. |
01-21-2024, 11:24 AM | #2 |
Wizard
Posts: 3,014
Karma: 18765431
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
What was the behaviour of your script? It is hard to know what part needs fixing without details.
|
Advert | |
|
01-21-2024, 11:38 AM | #3 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jan 2024
Device: PocketBook Verse Pro
|
Right now it works, but it misses the capability to display how much time is left until the device reboots.
When I tried to display the dialogs in the while loop, they did not refresh consistently (sometimes they did, sometimes they did not and the script waited until the dialog button was pressed until the display refreshed again). |
01-21-2024, 01:20 PM | #4 |
Wizard
Posts: 3,014
Karma: 18765431
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
Updating the display can be complicated because a process seems to need to be the active task to do that. Perhaps one of the other processes messes with that while your script is running. I expect it will get even worse when you run the process to listen to an audiobook simultaneously. Anyway, maybe you can figure it out using iv2sh to set the active task manually, but I have my doubts about that.
|
01-21-2024, 01:30 PM | #5 |
Junior Member
Posts: 3
Karma: 10
Join Date: Jan 2024
Device: PocketBook Verse Pro
|
Is there any documentation for all those binaries like iv2sh or dialog or run_script, etc. anyway?
|
Advert | |
|
01-21-2024, 01:38 PM | #6 |
Wizard
Posts: 3,014
Karma: 18765431
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
I doubt it. They were put there by pocketbook for their own purposes, and I doubt they expected them to be used generally. That said, "iv2sh -h" shows some help information, so there is that.
|
01-25-2024, 05:10 PM | #7 |
Connoisseur
Posts: 62
Karma: 87708
Join Date: Sep 2023
Location: Toulouse, France
Device: Vivlio Touch HD Plus
|
Code:
dialog ICON_CODE UNUSED_TITLE MESSAGE [BUTTON_ONE_LABEL] [BUTTON_TWO_LABEL] AFAICT UNUSED_TITLE is... unused, just use "". Button labels are optional. Exit status will tell what button was selected by user. Example: Code:
dialog 3 "" "Is flx listening to an audiobook or looking at hisereader screen" "Reading" "Don't know" Last edited by orontee; 01-25-2024 at 05:13 PM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
kobopatch: difference between "custom sleep timeout" and "larger sleep timeout" | Antioch | Kobo Developer's Corner | 0 | 02-05-2022 09:18 AM |
Feedback on "The server interface" and "The book reader" | Henning | Server | 4 | 05-24-2020 06:15 PM |
902 Want page to stay "open" when the PocketBook 912 goes off to sleep | FranTer | PocketBook | 4 | 03-12-2014 12:16 PM |
Does Calibre server work when computer is in "Sleep"/can it prevent Sleep | Backdraft | Calibre | 1 | 01-14-2011 08:47 PM |
"Balanced copyright" and feedback from real people (not just corporate "persons") | llreader | News | 16 | 02-15-2010 09:27 AM |