View Single Post
Old 11-08-2024, 11:29 PM   #17
neil_swann80
0000000000101010
neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.neil_swann80 ought to be getting tired of karma fortunes by now.
 
neil_swann80's Avatar
 
Posts: 5,895
Karma: 12981955
Join Date: Mar 2023
Location: An island off the coast of Ireland
Device: PB632 [HD3]
Seems like you only need to trigger user input if the "Digital Editions" directory is where the book is being opened from. So how about something like:
Code:
#!/bin/sh

appDir=/ebrmain/cramfs/bin
bookDir=$(dirname "$1")

function checkDir {
   if [ "$bookDir" == "/mnt/ext1/Digital Editions" ]; then digEdit=1
   else digEdit=0; fi
}

function default {
   exec /mnt/ext1/applications/koreader.app "$1"
   exit
}

function setKorRead {
   echo "$1":koreader.app >> /mnt/ext1/system/config/handlers.cfg
   exec /mnt/ext1/applications/koreader.app "$1"
}

function setPbRead {
   echo "$1":eink-reader.app >> /mnt/ext1/system/config/handlers.cfg
   exec $appDir/eink-reader.app "$1"
}

function askUser {
   $appDir/dialog 2 "" "Open $1 with:" "KOReader" "eink-reader" "Not now"; ans=$?
   if [ $ans == "1" ]; then setKorRead
   elif [ $ans == "2" ]; then setPbRead
   elif [ $ans == "3" ]; then default
   else askUser; fi
}

checkDir
if [ $digEdit == 1 ]; then askUser
else default; fi
exit
I've found you need to specify the path for the eink-reader.app file specifically within /ebrmain/cramfs/bin otherwise the Darkmode state is not respected. Same for dialog.

You could also use this script as a replacement for /mnt/ext1/system/bin/koreader.app as I previously suggested. This .app file is not overwritten by Koreader updates. It would mean the changes to extensions.cfg are not necessary.

Is user input even required if you can test for the "Digital Editions" directory? If not my initial much simpler script (now updated) would be sufficient.

Last edited by neil_swann80; 11-09-2024 at 06:49 AM.
neil_swann80 is offline   Reply With Quote