[mythtv-users] mythpowerbutton.sh improvements
Tom Lichti
tom at redpepperracing.com
Wed Oct 18 04:37:08 UTC 2006
I don't know about anyone else, but I have had a few issues with my wife
and daughter hitting the 'POWER' button to exit Myth (which I have setup
using Jarod Wilson's mythpowerbutton.sh script) while watching Live TV.
The problem is, this usually causes the backend to continue recording
Live TV, even though no-one is actually watching it. As you know, this
is not good, and the easiest fix is to restart the backend, but that's
not always so simple, especially if you are recording something that you
actually want on another tuner. Anyway, to cut to the chase, I created
an Expect script that telnets into the frontend, stops playback, and
then kills Myth. I am sharing it in case anyone else can benefit from it.
Tom
The revised mythpowerbutton.sh:
#!/bin/bash
PROG=mythfrontend
STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`
if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ]
then
if [ $STATUS -eq 0 ]
then
( $PROG > /var/log/mythfrontend.log & )
else
/usr/bin/expect /usr/local/bin/stopmythplayback.exp
sleep 3
killall $PROG
fi
fi
exit 0
And the expect script:
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn telnet localhost 6546
match_max 100000
expect -- "# "
send -- "play stop\r"
expect -- "# "
send -- "exit\r"
expect eof
More information about the mythtv-users
mailing list