Hi, if you are like me, and want to turn kodi off when tv is off and turn back on when tv is on here is a bash script for it
(it works for me on rpi2+osmc, also worked earlier with rpi+raspbmc obiously wiht a minimal change)
PS: this is for LG tv, as you can see in the code.
you can see waht is your tv with the command:
/opt/vc/bin/tvservice -n
and then replace GSM-LG_TV in the script with your version of tv.
Put this script into a file and add to crontab like:
crontab -e
and:
@reboot /bin/bash /PATH/YOUR_SCRIPT_FILE.sh >/dev/null 2>&1 &
Here is the script:
#!/bin/bash
oldcmd=""
while :
do
cmd=$(/opt/vc/bin/tvservice -n)
if [[ "$cmd" == *"GSM-LG_TV"* && "$cmd" != "$oldcmd" ]]
then
echo starting xbmc
$(sudo systemctl start mediacenter)
oldcmd=$cmd
elif [[ "$cmd" != "$oldcmd" ]] ; then
echo stopping xbmc
$(sudo systemctl stop mediacenter)
oldcmd=$cmd
fi
echo $cmd
sleep 10
done
after you have this script running, you can disable kodi from autostart after every boot:
sudo systemctl disable mediacenter
if you need later to autostart use this:
sudo systemctl enable mediacenter