Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > PocketBook > PocketBook Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 01-21-2024, 09:38 AM   #1
flx
Junior Member
flx began at the beginning.
 
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
So far this works on my PB Verse Pro. To make it a bit prettier, I was wondering if I could show the minutes left until the device goes to sleep on the screen (and, ideally, add some extend and cancel button). I suppose a bash script is not really supposed for this kind of work, but I will most certainly not start to learn C for this

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
Do you have any other ideas?

Last edited by flx; 01-21-2024 at 09:41 AM.
flx is offline   Reply With Quote
Old 01-21-2024, 10:24 AM   #2
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,985
Karma: 18343081
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.
rkomar is offline   Reply With Quote
Advert
Old 01-21-2024, 10:38 AM   #3
flx
Junior Member
flx began at the beginning.
 
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).
flx is offline   Reply With Quote
Old 01-21-2024, 12:20 PM   #4
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,985
Karma: 18343081
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.
rkomar is offline   Reply With Quote
Old 01-21-2024, 12:30 PM   #5
flx
Junior Member
flx began at the beginning.
 
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?
flx is offline   Reply With Quote
Advert
Old 01-21-2024, 12:38 PM   #6
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 2,985
Karma: 18343081
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.
rkomar is offline   Reply With Quote
Old 01-25-2024, 04:10 PM   #7
orontee
Connoisseur
orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.orontee invented the internet.
 
orontee's Avatar
 
Posts: 52
Karma: 84266
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]
Meaning of ICON_CODE: 0 no icon, 1 information icon, 2 question mark icon, 3 warning icon, 4 error icon.

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"
Attached Thumbnails
Click image for larger version

Name:	scr0018.png
Views:	40
Size:	54.9 KB
ID:	206024  

Last edited by orontee; 01-25-2024 at 04:13 PM.
orontee is offline   Reply With Quote
Reply


Forum Jump

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 08:18 AM
Feedback on "The server interface" and "The book reader" Henning Server 4 05-24-2020 05:15 PM
902 Want page to stay "open" when the PocketBook 912 goes off to sleep FranTer PocketBook 4 03-12-2014 11:16 AM
Does Calibre server work when computer is in "Sleep"/can it prevent Sleep Backdraft Calibre 1 01-14-2011 07:47 PM
"Balanced copyright" and feedback from real people (not just corporate "persons") llreader News 16 02-15-2010 08:27 AM


All times are GMT -4. The time now is 05:47 PM.


MobileRead.com is a privately owned, operated and funded community.