DPMS monitor control via remote control on Myth TV

I am using an LCD monitor as the display for my MythTV box, connected via an analog RGB (a.k.a. VGA) cable. This allows me to use DPMS (Display Power Management Signaling) to turn the monitor on and off from the MythTV box.

Instructions for setting this up with MythTV are here , but I found that I had to make a few changes to get things to work correctly. I modified one line of the shell script  as follows:

STATUS=$( xset -q | grep "Monitor is" | awk '{print $3}' )

To trigger the monitorpowerbutton.sh script, I placed the following into my /etc/lirc/lircrc file:

begin
 prog =  irexec
 button = TV_POWER
 repeat = 4
 config = /usr/local/bin/monitorpowerbutton.sh
end

Now my TV_POWER button toggles the power state of the monitor!