[mythtv-users] How can I know if the mythtv is idle?
Phill Edwards
philledwards at gmail.com
Fri Nov 11 02:22:12 EST 2005
> I'm doing a script to shutdown the computer and I would like to know if mythtv
> is idle and in that case, delay the shutdown process until everything is
> done.
>
> I thought that there was a DCOP server and with that I could know the idle
> time, but I doesn't work (or isn't implemented at all).
>
> If I can't get the idle time, there other way is: ¿what things are evaluated
> in order to set the idle time?
This is how I check for idle - these functions check a) if there's
anything going on that I might want to allow to complete before
shutting down and b) if anything's being recorded. I call these from
another shell script which then decides what to do.
<snip>
#!/bin/bash
# Function library
#
# -----------------------------------------------------------------------
# Check if any important myth functions are running, such as frontend,
# transcoding, commercial flagging, nuvexporting, listings grabbing.
# -----------------------------------------------------------------------
myth_busy()
{
FRONTEND=`ps -e | grep mythfrontend | grep -v grep | wc -l | awk '{print $1}'`
COMMFLAG=`ps -e | grep mythcommflag | grep -v grep | wc -l | awk '{print $1}'`
TRANSCODE=`ps -e | grep mythtranscode | grep -v grep | wc -l | awk '{print $1}'`
TV_GRAB=`ps -e | grep tv_grab_au.sh | grep -v grep | wc -l | awk '{print $1}'`
NUVEXPORT=`ps -e | grep nuvexport | grep -v grep | wc -l | awk '{print $1}'`
if [ $FRONTEND -eq 0 ] && [ $COMMFLAG -eq 0 ] && [ $TRANSCODE -eq 0 ]
&& [ $TV_GRAB -eq 0 ] && [ $NUVEXPORT -eq 0 ]
then
return 0
else
return 1
fi
}
# -----------------------------------------------------------------------
# Check if any of the tuners are recording by getting the backend
# status xml from port 6544 and parsing the output.
# -----------------------------------------------------------------------
myth_recording()
{
TNRNUM=1 # Init the count of number of tuners in system
while [ $TNRNUM -le 2 ]
do
TNRSTS=`wget --quiet --output-document=- http://elm.edwards.home:6544/xml | \
grep "<Encoder .*id\=\"$TNRNUM\"" `
# If the state="0" in the XML then nothing's recording on that tuner.
echo $TNRSTS | grep --quiet state\=\"0\"
if [ $? -gt 0 ]
then
return 1
fi
TNRNUM=`expr $TNRNUM + 1`
done
return 0
}
</snip>
Regards,
Phill
More information about the mythtv-users
mailing list