[mythtv-users] Shell script to turn monitor off that almost works

Dave M G martin at autotelic.com
Mon Jan 17 15:00:00 UTC 2011


MythTV users,

I am using Mythbuntu 10.10 with a Hauppauge PVR-150.

I have in my .lircrc configuration file a command that calls a shell
script for the purpose of turning off the screen.

The entry in .lircrc looks like this:

# Green Power button
begin
prog = irexec
button = Power
config = /home/media/.lirc/powerbutton.sh
end

"powerbutton.sh" is a script I picked up off the web that is intended to
make it so that the green power button acts as a toggle. If the screen
is on, then pressing it turns off. If the screen is off, then pressing
it turns it on.

It works... almost. What it does is turn of the screen, and then a few
seconds later, the screen comes on again. Then I hit the green power
button again, and this time the screen goes off and stays off.

If the screen is off and I want to turn it on, that works fine. No need
to press it twice. The problem only occurs when trying to turn the
screen off.

I'm wondering if there's a way I can configure the shell script - or use
any other method - to make it so the screen turns off and stays off the
first time I hit the button.

The contents of the shell script follow. I picked it up off the web, and
I know little about shell scripting, so I can not vouch in any way for
the contents.

Any advice would be much appreciated.

#!/bin/bash

VOLUME=$(aumix -vq | awk '{ print $3 }' )
MONITOR=$( xset -q | grep Monitor | awk ' { print $3 $4 } ' )

case "$MONITOR" in
"On")
xset dpms force standby
if [ "$VOLUME" != "0" ] ; then
mute
fi
;;
*)
xset dpms force on
if [ "$VOLUME" == "0" ] ; then
mute # unmute actually, but it is the same script.
fi
;;
esac

-- 
Dave M G


More information about the mythtv-users mailing list