LinHES Forums http://forum.linhes.org/ |
|
Mapping remote to shell scripts or gdm restart? http://forum.linhes.org/viewtopic.php?f=6&t=10275 |
Page 1 of 1 |
Author: | andyem [ Tue May 30, 2006 10:03 am ] |
Post subject: | Mapping remote to shell scripts or gdm restart? |
Sometimes when I leave the frontend machine running for a few days and decide to watch a recording, one the recording ends the mythfrontend just kicks out back into X11. Of course just starting the mythfrontend again or sometimes i just run /etc/init.d/gdm restart so I know all is fresh. The problem goes away till the next time. Even though I know knoppmyth is beta and errors happen is there a way I can map remote buttons to perform the gdm restart command or to run a certain shell script I have prepared so I dont have to log in through ssh or use the keyboard and mouse the machine has attached to it. The only posts I see are for mapping remote commands for use within mythtv, which I have easily done. Anyone else try anything like this? I could maybe even use it to run maintenance scripts or pretty much anything I want for that matter ![]() Thx |
Author: | afrosheen [ Tue May 30, 2006 11:27 am ] |
Post subject: | |
This has been mentioned and detailed before. One click of the power button on the remote does a soft (frontend) restart and two clicks does a Knoppmyth reboot. I'll try to dig around and find it, I need it anyway since my upgrade lost that shell script. |
Author: | andyem [ Tue May 30, 2006 11:34 am ] |
Post subject: | |
very nice thx i'll try checking a little deeper also ![]() |
Author: | andyem [ Tue May 30, 2006 11:42 am ] |
Post subject: | |
Heres what I got so far: Code: Following Jarod Wilson’s Tips ‘n Tricks, the green Power button on the Hauppauge remote can now stop and start the MythTV front-end. This is really handy on the odd occasion when it freezes up for one reason or another. I just had to add the lines begin prog = irexec button = OFF repeat = 4 config = /usr/local/bin/mythpowerbutton.sh end to my ~/.lircrc file, and create the script /usr/local/bin/mythpowerbutton.sh containing #!/bin/bash PROG=mythfrontend STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'` if [ $STATUS -eq 0 ] then ( $PROG & ) else killall $PROG fi exit 0 Here is where he got the snippet from Jared's write up: Code: Once in a blue moon, my wife calls me at work saying she messed something up, and doesn't know what to do. While its rare anymore that I see a frontend lockup, its annoying to have to shell in from work to kill it off and restart it. So I finally got around to implementing something a number of others had suggested on the mailing lists, and the power button on my remote now executes a script via irexec that kills the frontend if it is running, and starts it up if it isn't. So two quick key taps, and my wife can recover the frontend, instead of calling me. :-)
First off, I edited my ~/.lircrc file to include the following stanza: # Power Button begin prog = irexec button = OFF #button = POWER # (for my RS15-2116 remote) repeat = 4 config = /usr/local/bin/mythpowerbutton.sh end Note that we need irexec running to make this all work. It should already be getting launched by my myth-load.sh script, detailed in the main HOWTO. And finally, I created a trivial little shell script in /usr/local/bin/, called mythpowerbutton.sh. The basic contents of it are: #!/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 & ) else killall $PROG fi fi exit 0 Remember to make that executable (# chmod +x /usr/local/bin/mythpowerbutton.sh), and either log out and back in or start up irexec manually to see it function. I'd also remove any other .lircrc sections pertaining to the POWER button, or you may see multiple things happen at once. Not sure yet what will happen if I hit the button while, say, xine is in the foreground... I cant wait to try this. |
Author: | afrosheen [ Tue May 30, 2006 11:44 am ] |
Post subject: | |
Ok, this was a tricky one to dig up via the search feature, but here's how it's done. First create a shell script exactly like this one. Make sure you KNOW where you put it. Code: #!/bin/bash # Script for powerbutton press on Mythtv. Double click (within # timeout) will reboot, single press will restart frontend # /home/mythtv/scripts/mypower.sh # # Adopted from someone a long time ago. Sorry for not # remembering who. DOUBLE_PRESS_TIMEOUT=2 SCRIPTNAME=`basename $0` OLDEST_SCRIPT_PID=`pgrep -o $SCRIPTNAME` OUR_PID=$$ # check if we are the oldest instance of this script if [[ "$OLDEST_SCRIPT_PID" == "$OUR_PID" ]] then killall mythfrontend sleep $DOUBLE_PRESS_TIMEOUT mythfrontend & else # this is a doublepress kill $OLDEST_SCRIPT_PID sudo reboot fi That's the script that does all the magic. Next, add this to your /home/mythtv/.mythtv/lircrc file Code: ### RESET THE MYTH BOX or REBOOT IT
# 1 click is reset front end, 2 clicks is reboot # begin prog = irexec button = Power config = /home/mythtv/scripts/mypower.sh & end WARNING: This WON'T work if 1. you don't put the script in /home/mythtv/scripts, 2. irexec isn't installed and 3. you don't have a mapping called "Power" in /etc/lircd.conf. All 3 elements are critical. Also don't forget to chmod a+x that mypower.sh script when you're done. Edit: Oops, sorry for the same post after yours but at the time I hit the page you hadn't responded. Go real time. ![]() |
Author: | andyem [ Tue May 30, 2006 5:47 pm ] |
Post subject: | |
Hey no probs. I actually followed Jareds and it worked perfect. THe only minor change was my Green Power Button is linked to the word Power not OFF but everyones will be different or I could have changed it in my etc/lircd.conf. Either way it works great. Thx bud |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |