Project

General

Profile

"Advanced" shutdown after recording

Added by Hauke Hagedorn over 11 years ago

this one might come in handy for those who have TVH and XBMC both on the same machine.

the shutdown/suspend script in the ACPI-Wakeup-Howto is executed after every recording, regardless of whether XBMC is running or not.
to increase the WAF and not getting in trouble to have your HTPC restarted while you actually want to watch TV or listening to some music, you might want to use this one:

#!/bin/sh

# Here you can invoke your script for recording's post-processing
#exec <your_script.sh>

#Edit to suit your needs

        XBMCHOST=localhost
        XBMCPORT=9777
        WAITTIME=20  #Some extra time to wait - ensuring the recording is fully written to disk!
#END Edit

echo "Waiting $WAITTIME seconds";
sleep $WAITTIME
if [ "$(pgrep xbmc)" ]
 then
        logger "XBMC still running, not shutting down Sytem - trying to update its video lib instead" 
        if [ -f /usr/bin/xbmc-send ]
         then
                xbmc-send --host=$XBMCHOST --port=$XBMCPORT --action="UpdateLibrary(video)" | logger
         else
                logger "xbmc-send not installed, please install!" 
        fi
        exit 0;
else
        /sbin/shutdown -h now
fi

as "pidof" didn't work for me, i check if XBMC is running via pgrep. IF it's running, the script will try to update XBMC's video library.
maybe there are other tweaks, like no shutdown, if the next timer is just a few minutes later, but this one will do for me just fine.


Replies (1)

RE: "Advanced" shutdown after recording - Added by B. J. about 11 years ago

Thanks for your work, but I don't agree that advanced shutdown is a task for tvheadend. This task should do the "master control program" (in this case xbmc is mcp). As tvheadend 'only' serves/record tv and the user decide to shutdown/poweroff the system - mcp has to taken full control and has to lookup for running/upcoming tasks (recordings, epg-updates, network activity, postprocessors), shutdown later and/or set wakeup-timers.

See my announcement here: http://forum.xbmc.org/showthread.php?tid=115758

    (1-1/1)