View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 11 posts ] 
Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject: Power off via remote?
PostPosted: Sun Jan 27, 2008 7:06 pm 
Offline
Joined: Sat Apr 21, 2007 6:55 pm
Posts: 306
Location: CA,USA
Hi All,

I would like to be able to hit the power button on my remote and have it shut down my front-end. Sounds simple I know..... Lirc etc is working fine & there is a 'Power' button defined in my lircd.conf. I added the lines below to my lircrc file but no joy. I guess it's some kind of auth problem?

Running R5F27. Searched this site, wiki & google with a surprising lack of luck...

Code:
begin
    prog = irexec
    button = Power
    config = /sbin/halt
end


Thanks,

_________________
Paul O'Flynn


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 8:34 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,

Just curious as to why you would want to shutdown the fe? I wired my remote to restart the fe any time I hit the green pwr button. Very handy when I accidently get into a keyboard app and then remember I left the keyboard in another room .

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 9:37 pm 
Offline
Joined: Sat Apr 21, 2007 6:55 pm
Posts: 306
Location: CA,USA
mjl wrote:
Hi,

Just curious as to why you would want to shutdown the fe?
Mike


Jeez, I would have thought it would have been a very common request, but apparently not. I start up the fe, watch a movie for an hour or two and then I want to power it down w/o jumping through all the menus. The be is running 27x7 in the garage. Seems common enough I would have thought.

I hear ya w.r.t. the keyboard app thing but I don't hit that too often and just VNC in when it's that bad. So what's your entry for the restart cmd?

_________________
Paul O'Flynn


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 10:02 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,,
Brain cramp on my part. Never occurred to me that you were running a remote fe..

any way, I just add to the .mythtv/lircrc
# Restart Mythfrontend
begin
prog = irexec
button = Power
config = /usr/bin/run-restartmyth.sh &
end

which calls (make executable)
/usr/bin/run-restartmyth.sh
Code:
#!/bin/sh
# Green Power button for FrontEnd restart
lsmod |grep "ivtvfb "|cut -b1-6 >/tmp/tv
if [ $(cat /tmp/tv) = "ivtvfb" ]; then
fontsize="26"
fontcolor="lightyellow"
else
fontsize="34"
fontcolor="yellow"
fi
if ps aux | pgrep mythfrontend
then
        #Allow 5 seconds for Lirc to send Escape to MythFrontend
        export FONT="-adobe-helvetica-bold-*-*-*-$fontsize-*-*-*-*-*-*-*"
        export DISPLAY=:0
        echo  "Restarting KnoppMyth Frontend" > /tmp/ver
        cat /tmp/ver | osd_cat --delay=5 --font=$FONT --shadow=2 --color=$fontcolor --pos=bottom --align=centre
        sleep 5
        killall mythfrontend
        mythfrontend &
else
        mythfrontend &
fi


Please note that this not all my code, some is "borrowed" but sadly I didn't mark from whom.

To make it halt I use this: (make executable)
/usr/bin/halt-control
#<code>
#!/bin/bash
# Shutdown mesage
lsmod |grep "ivtvfb "|cut -b1-6 >/tmp/tv
if [ $(cat /tmp/tv) = "ivtvfb" ]; then
fontsize="26"
fontcolor="lightyellow"
else
fontsize="34"
fontcolor="yellow"
fi
killall xterm
sudo killall mythfrontend&
echo "Starting Backup, followed with Shutdown" > /tmp/ver
echo "This may take a few minutes...." >> /tmp/ver
export DISPLAY=:0
export FONT="-adobe-helvetica-bold-*-*-*-$fontsize-*-*-*-*-*-*-*"
cat /tmp/ver | osd_cat --delay=180 --font=$FONT --color=$fontcolor --shadow=2 --pos=middle --align=centre&
festival --tts /tmp/ver >/dev/null
(play /usr/share/sounds/beg.wav) > /dev/null
sleep 1
sudo /usr/local/bin/mythbackup
killall osd_cat
(play /usr/share/sounds/end.wav)& > /dev/null
sleep 3
sudo halt
#<end code>

You can modify this as needed, change the label in the remote button and call it from the green power.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 10:58 pm 
Offline
Joined: Sat Apr 21, 2007 6:55 pm
Posts: 306
Location: CA,USA
mjl wrote:

You can modify this as needed, change the label in the remote button and call it from the green power.

Mike


I did - I made a script file with basically nothing but 'sudo halt' in it ;-) Do I really need all that other stuff? It seems it is all built around the fact that you want to do a backup first.

Thanks for reminding me to make it executable, I'm sure I would have forgotten that, not being a unix-head. Well, this script seems to work. A quick question though, would it be a bad idea to hit this power button while playing a movie or live TV or whatever? Just wondering if 'sudo halt' might force some apps to shut down in a not-so-nice way.

Thanks!

_________________
Paul O'Flynn


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 11:14 pm 
Offline
Joined: Sun Jun 12, 2005 10:55 pm
Posts: 3161
Location: Warwick, RI
Hi,

I'm lazy, could have stripped out all the extra stuff but then you would not have had as much fun :)

Linux shuts down gracefully. From what I understand is when you tell it to end the working day, it goes around and tells everyone else to shutdown their work and then starts the shutdown of the system. Hopefully someone can shed more light.

Mainly when I hit the green button, I want feedback that I pressed the button. The script kills the frontend, kills any xterms I may have open and cleans up as it drops back to the desktop which is pretty obvious that I did press the button. It then tells me what is going to happen as it begins doing a backup and finally shuts down and turns my box off.

The first part just makes it fit on a tv screen if there is one being used.

Hope that was what you were after.
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 27, 2008 11:21 pm 
Offline
Joined: Sat Apr 21, 2007 6:55 pm
Posts: 306
Location: CA,USA
Good point re. user feedback. Thanks for all of your help, you can go to bed now, it's late ;-)

Thanks!

_________________
Paul O'Flynn


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 28, 2008 5:10 pm 
Offline
Joined: Sat Sep 02, 2006 9:17 am
Posts: 359
mjl wrote:
Linux shuts down gracefully. From what I understand is when you tell it to end the working day, it goes around and tells everyone else to shutdown their work and then starts the shutdown of the system. Hopefully someone can shed more light.

For all intents and purposes this is true. Any daemon process gets a chance to go quietly via the init scripts. Eventually if something is hung there will be a chance to go kicking and screaming via a "kill" command and if that fails they get terminated via "kill -kill" User processes are another matter they usually just exit. So, if you've been typing your 600-page Great American Novel, and forgot to save /sbin/halt will result in your editor exiting without ever showing you the "Do you want to save?" dialog. I'm not aware of any Myth front-end problems with exiting in this manner, (maybe MythMusic playlist editing??) If you kill the frontend while streaming from the backend, the backend will figure it out, and move on just fine.

The other command I like is /sbin/shutdown, if you're really concerned about your novel work, 'shutdown -h +5 "Shutdown requested by Green Button Press"' Will send the message to every open XTerm and console window (I think some window managers even display it) The +5 starts a 5 minute countdown. Any time in the 5 minutes you can run (as root) 'shutdown -c' to cancel the shutdown. If you have remote logins and feel like being a BOFH, there's always 'shutdown -h now pblhht\!'


Top
 Profile  
 
PostPosted: Sat Feb 02, 2008 2:20 am 
Offline
Site Admin
Joined: Fri Sep 19, 2003 6:37 pm
Posts: 2659
Location: Whittier, Ca
Hello,

poflynn wrote:
Code:
begin
    prog = irexec
    button = Power
    config = /sbin/halt
end


Try
Code:
config = sudo /sbin/halt
In place of what you have above.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 12:46 pm 
Offline
Joined: Wed Jan 04, 2006 10:20 am
Posts: 387
Location: South New Jersey, USA
Nice simple solution Cecil. Had it up and working on my FE in about 5 minutes. Also kudos to poflynn for suggesting a solution to a problem that I didnt realize I had :D

_________________
LINHES 8.6.1 BE/FE - MSI K9N6SGM-V with AMD A64 X2 4600+, 4GB Ram. 1.5TB WD. HDHR Prime. Nvidia GT210. MCE remote.
FrontEnd - Dell Vostro 400 3.0GHz Core2Duo NVidia GeForce210. MCE Remote


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 2:44 pm 
Offline
Site Admin
Joined: Fri Sep 19, 2003 6:37 pm
Posts: 2659
Location: Whittier, Ca
Simple solutions.... I try. :)


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 


All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu