OK, here's the log: http://0x0.st/opx_.log
I boot up, call the Power menu with a keypress on my remote control and select "Shutdown" from the menu. This does System.Exec() the above script.
That said, it appears to me that Da Flex is right. From the log it looks like after invoking "Shutdown", kodi is kinda "un-pausing", doing HW inits etc.
Also, with a trick I can make my scripts work: I just sleep for 2 seconds before sending the kodi-send commands, which is enough for Kodi to be attentive again and react to those commands. For that to work, the script has to immediately return and do the sleeping in the background. For that I moved everything into a function.
That's the working script:
#!/bin/bash
# Check if anything gets downloaded and prevent shutdown
# Set this script in Kodi's Power menu with "System.Exec()"
action() {
# Make sure kodi is running after being stopped by the Power menu
sleep 2
if [ -e /tmp/downloadflag ] ; then
echo "Download in progress. Shutdown aborted!"
kodi-send --action="Notification(Download in progress,Shutdown aborted!,20000)"
else
echo "Shutdown!"
kodi-send --action=Powerdown
fi
}
action &
Display More
Though it's working, I'd be willing to experiement further, if you guys come up with things to try...
Thanks so far!