9 June 2008 - 14:03Screen Blanking MythTV

So very recently I setup up another mythtv pvr that runs in my bedroom. The point of this was to encourage me to get to bed at a decent hour and to put a stop to me falling asleep on the couch.

The setup went okay, although I must admit I encountered some issues with the whole frontend/backend slave setup which I will detail in a later post.

This post is about blanking the screen as I often fall asleep while watching a movie or show. This increases the chance of screen burn in, and is something I want to avoid.

I am still researching how this can be done automatically but in the interim I have come up with the following solution. I have setup the power button on my hauppauge remote to execute a script with changes the runlevel from 5, to 3. Essentially stopping the frontend and bringing the system down to a terminal.

Since most default installs automatically blank the terminal after a set period of time of inactivity I am set. Now when I am drifting off and far to cozy to get out of bed to shut off the monitor I can simply press power and let the system enter runlevel 3. Then after a few minutes the screen will blank automatically.

To get this to work I added the following configuration to the .lircrc file in /home/mythtv.

# Power Button begin
prog = irexec
button = Power
config = /home/mythtv/powerbutton.sh
end

With that done the next step is to create the actual script that will switch runlevels. (Keep in mind this assumes your mythtv user has sudo access to run the init command) The following script is run from /home/mythtv/powerbutton.sh.

#!/bin/bash
 
RL=`/sbin/runlevel | awk '{print $2}'`;
LOG="/home/mythtv/pb.log";
 
if [ $RL -eq 5 ]
then
   # shutdown
   sudo /sbin/init 3;
   printf "`date`: powerbutton.sh: [$RL] switching to runlevel 3\n" >> $LOG
   killall irexec
   sleep 1;
   /usr/bin/irexec &
   printf "`date`: powerbutton.sh: starting irexec.\n" >> $LOG
   sleep 1;
   setterm -reset
   printf "`date`: powerbutton.sh: resetting terminal.\n" >> $LOG
   sleep 20;
   RL=`/sbin/runlevel | awk '{print $2}'`;
   printf "`date`: powerbutton.sh: switched to [$RL], exiting.\n" >> $LOG
else
   # startup
   sudo /sbin/init 5;
   printf "`date`: powerbutton.sh: [$RL] switching to runlevel 5\n" >> $LOG
   sleep 20;
   RL=`/sbin/runlevel | awk '{print $2}'`;
   printf "`date`: powerbutton.sh: switched to [$RL], exiting.\n" >> $LOG
fi
exit 0

With that done, all that is left is to test it out. Of course you will need to either reboot to pickup the changes or restart lircd, then the mythtv frontend.

Keep in mind this is just temporary solution and not something I plan to keep doing. I know there are probably far better ways of doing this and I will be looking into them in the future.

No Comments | Tags: mythtv

Add a Comment