I think I have a somehow workable solution now.
First, I put this in a file
/mnt/ext1/system/bin/askwhichreader.app
Code:
#!/bin/sh
dialog 2 "" "Open $1 with:" KOReader eink-reader "Not now"
ans=$?
if [ $ans == "1" ]; then
echo "$1":koreader.app >> /mnt/ext1/system/config/handlers.cfg
/mnt/ext1/system/bin/koreader.app "$1";
fi
if [ $ans == "2" ]; then
echo "$1":eink-reader.app >> /mnt/ext1/system/config/handlers.cfg
eink-reader.app "$1";
fi
Second, I modified these lines of
extensions.cfg:
Code:
pdf:@PDF_file:1:askwhichreader.app,koreader.app,eink-reader_with_pdfium.app,eink-reader_with_rmsdk.app:ICON_PDF
epub:@EPUB_file:1:askwhichreader.app,koreader.app,eink-reader.app:ICON_EPUB
and removed my previous attempts of writing there a line for acsm:@ACSM_file:1.
Now what happens when I tap on an .acsm file is the following:
- the full book is downloaded, while the icon in the librarian shows an animation with the progressing percentage;
- the resulting epub or pdf is created in /mnt/ext1/Digital Editions (in contrast to what I wrote above, not in the same dir as the .acsm)
- the dialog asking which program to use comes up
- the book opens in the reader chosen
After that, the association becomes permanent, because it is written in handlers.cfg. The fact that the new line is initially appended at its end doesn't seem to create problems, the file is subsequently reordered alphabetically by the OS.
The same dialog should pop up also any time an unassociated new file is opened for the first time. And if I want at later time to change its reader association, I can always use the long press pop-out chooser menu.
I have still to test this solution on the long run, but it seems reasonably ok. Instead of choosing automatically the reader program as part of the downloading pipeline, which I was not able to intercept, there is one more tap on the dialog involved, but it's imho already an improvement.