I've been scratching my head over this.
The below NM config displays
Done when the script process is spawned and not when the Pocket image conversions are done.
Code:
menu_item:library:Fix Pocket Images:cmd_spawn:quiet:/bin/sh /mnt/onboard/.adds/pocket/fix.sh
chain_success:dbg_toast:Done
I thought using
cmd_output instead of
cmd_spawn so that the script has a chance to indicate when it is done might sort it out:
Code:
menu_item:library:Fix Pocket Images:cmd_output:500:/bin/sh /mnt/onboard/.adds/pocket/fix.sh
chain_success:dbg_toast:Done
But this would mean that the script would need to provide some sort of output that it was done. So I modified it to the below (apologies for the amateur code):
Code:
#!/bin/sh
ARTICLES="/mnt/onboard/.kobo/articles"
CONVERT="/mnt/onboard/.adds/pocket/convert -limit time 60"
IDENTIFY="/mnt/onboard/.adds/pocket/identify -limit time 60 -quiet"
PROCESSED="0"
LD_LIBRARY_PATH="/mnt/onboard/.adds/pocket/lib:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
for i in $(find $ARTICLES -type f -not -iname "*.html"); do
FORMAT=$($IDENTIFY -format "%m" "$i")
if [ "$FORMAT" == "PNG" ]; then
$CONVERT "$i" "$i.jpg"
if [ $? -eq 0 ]; then
mv "$i.jpg" "${i%.jpg}"
(($PROCESSED)) || PROCESSED="1";
fi
fi
done
if [ "$PROCESSED" == "1" ]; then
echo "DONE: Pocket articles optimised";
else echo "NOTE: Pocket articles not/already optimised";
fi
However,
cmd_output message box pops up an error stating that there was a timeout.
Any idea what I'm doing wrong?