[mythtv-users] starting amp from MythTV
Richard Morton
richard.e.morton at gmail.com
Tue Dec 14 19:34:04 UTC 2010
I resolved this by writing a very simply script and starting it once
an hour with cron. This requires two keys to be setup in LIRC. It is
designed (and tested on) an amp which has separate power on and off
buttons, but only a minor change is required for amps that have a
single toggle button. At that moment if the menu is showing and the
script is restarted a confirmation on or off signal is sent.
R
#!/bin/bash
PATH=/usr/bin:/bin
# loop for just over an hour; so the next start of the
# script (in an hours time, started using CRON) slightly overlaps
for ((i=0;i<=3690;i+=1))
do
# determine if power management is disabled (playback
# is in progress); in which case skip changing the
# amp power with an IR signal. And set the previous
# state as monitor is on for next comparison.
DPMS=`xset -q -display :0.0 | grep "DPMS is Disabled"`
DPMSSTATE=${DPMS:2:16}
if [ "$DPMSSTATE" = "DPMS is Disabled" ]
then
PREVIOUSSTATE="Monitor is On"
# echo "DPMS is Disabled; therefore Monitor is On"
else
# get monitor state; on or off
MONITOR=`xset -q -display :0.0 | grep "Monitor is"`
MONITORSTATE=${MONITOR:2:13}
# echo $MONITORSTATE
if [ "${MONITORSTATE}" = "Monitor is On" ]
then
# if the PreviousState isnt set, or is the same
# dont send the IR signal, or vice versa
if [ "${PREVIOUSSTATE}" != "Monitor is On" ]
then
# irsend goes here to turn amp on
/usr/bin/irsend SEND_ONCE RC-901 KEY_POWER
fi
else
if [ "${PREVIOUSSTATE}" != "Monitor is Of" ]
then
# irsend goes here to turn amp off
/usr/bin/irsend SEND_ONCE RC-901 KEY_POWER2
fi
fi
# set the current state as the next state for the
# next run around the loop.
PREVIOUSSTATE=$MONITORSTATE
fi
# wait a second and run the loop again
sleep 1
done
More information about the mythtv-users
mailing list