View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 37 posts ] 
Go to page 1, 2, 3  Next

Print view Previous topic   Next topic  
Author Message
Search for:
PostPosted: Sun Oct 24, 2004 8:04 pm 
Offline
Joined: Mon Jan 26, 2004 2:07 pm
Posts: 32
NOTE: this can be used to restart whatever you want, but here I use to to restart mythfrontend ;)

Well, I'm sure all of you at one point in time have had mythfrontend crash on you. It's easy to restart, but if your loved one(s) use your mythtv box, they may not be able to! Well, here is an easy way to be able to use your remote to easily restart mythfrontend! The following will cause a small box to pop up onscreen allowing you so select whether or not you'd like to restart mythfrontend.

Note: I have a Hauppauge PVR-250 remote, if you don't you may have to adjust the buttons accordingly

Without further adue...

We will be using irexec and irxevent to do this, as well as xdialog to make the popup, so first:

Code:
apt-get update && apt-get install lirc-x xdialog


Note, this will move your /etc/lircd.conf to /etc/lirc/lircd.conf, so you will have to copy it back.

Next we have to configure irxevent and irexec to start when X is started, so we add the following lines to /home/.fvwm/.fvwm2rc (this is at the bottom of the file)

Code:
#Remove comment to start irxevents
exec irxevent &
exec irexec &


Also, we want to change the focus model in .fvwmrc to make the popup box come to the front, and focus, so make these changes to the .fvwm2rc file as well:

Comment out
Code:
#ColormapFocus FollowsMouse


and add
Code:
Style * GrabFocus, GrabFocusTransient


Then comment out
Code:
#Style *           FocusFollowsMouse


And save.

With that done, we will now create a simple script to make the popup:

With your favourite editor, create a file (I called mine restartmyth.sh) with the following in it:

Code:
#!/bin/sh

 Xdialog --title "Restart MythTV" --yesno "Would you like to restart
 MythTV?" 0 0

 if [ $? -eq 0 ]
 then
     killall mythfrontend
     mythfrontend &
fi


Then copy it to somewhere in your path...I chose /usr/bin.

Next, give proper permissions to mythtv user, so (as root):

Code:
chown root:mythtv /path/to/yourfilename.sh
chmod 770 /path/to/yourfilename.sh


Next, we want to bind this script to a key on the remote, so edit your /home/mythtv/.lircrc and add these lines:

Code:
begin
   prog = irexec
   button = Go
   config = restartmyth.sh &
end

begin
    prog = irxevent
    button = Ok
    repeat = 0
    config = Key KP_Enter CurrentWindow
end

begin
    prog = irxevent
    button = Vol+
    repeat = 3
    config = Key Right CurrentWindow
end

begin
    prog = irxevent
    button = Vol-
    repeat = 3
    config = Key Left CurrentWindow
end



Note, you can configure the buttons to be whatever you want. Note that I set "GO" to launch this popup dialog, and I set left and right and OK buttons so I can go back and forth and select. Also note that if you bind the left and right keys using irxevent, you will want have to comment out the other left/right keybindings in your .lircrc or else you will be passing the commands twice ;)

Now, save, and reboot...that's it!

Enjoy.


Last edited by Spektr on Mon Oct 25, 2004 5:28 pm, edited 2 times in total.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 10:41 pm 
Offline
Joined: Mon Nov 17, 2003 8:59 am
Posts: 206
Location: Michigan
Nice. :) You'd better go edit the typo above before a newbie hoses his box though. apt-get update, not upgrade! ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 5:37 am 
Offline
Joined: Mon Jan 26, 2004 2:07 pm
Posts: 32
LOL, thanks for catching that, it was pretty late when I wrote that all out ;)

davem wrote:
Nice. :) You'd better go edit the typo above before a newbie
hoses his box though. apt-get update, not upgrade! ;)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 9:09 am 
Quote:
you will want have to comment out the other left/right keybindings in your .lircrc or else you will be passing the commands twice


Hmm.. does this mean when I use these settings, I can't use the left and right keys anywhere else? That would be a shame because I use them all the time watching tv or dvd's!


Top
  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 5:27 pm 
Offline
Joined: Mon Jan 26, 2004 2:07 pm
Posts: 32
Nope, you just don't need duplicates. To briefly explain...if you have, (on hauppauge) Vol+ bound to "Right", and you do what I have laid out above, you have irxevent binding "Vol+" to right as well. So just get rid of any other bindings of Vol+ to right except for irxevent, and it'll work great :) I obviously use the left/right keys a lot for navigation and volume control and whatever else, so I can guarantee that I made sure this was working right ;) If you want to see my .lircrc, or need help with yours, let me know.

mjvdvlugt wrote:
Quote:
you will want have to comment out the other left/right keybindings in your .lircrc or else you will be passing the commands twice


Hmm.. does this mean when I use these settings, I can't use the left and right keys anywhere else? That would be a shame because I use them all the time watching tv or dvd's!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 5:51 pm 
Offline
Joined: Sat Feb 21, 2004 11:54 am
Posts: 48
Spektr,

Thanks for this information! I always wanted some way to easily respawn MythFrontend when it crashes. For what it's worth, I did not even really want the dialog asking whether or not to restart the frontend (I was content with the frontend restarting immediately after pressing GO), so I modified restartmyth.sh to be just this:

Code:
#!/bin/sh

killall mythfrontend
mythfrontend &


I'd also chopped down your .lircrc to just this

Code:
begin
   prog = irexec
   button = Go
   config = restartmyth.sh &
end


I suspect for anybody else out there that just wants this immediate respawning, the apt-get would not be neccessary and only the exec lines in the .fvwm2rc would be needed.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 11:30 pm 
Offline
Joined: Mon Jan 26, 2004 2:07 pm
Posts: 32
aelinuxguy, no problem...you can cut down and edit out a lot of that stuff, but you still DO need to install lirc-x to get irxevent and irexec, from what I could find they aren't install on knopppmyth by default. Therefore you can't cut out the apt-get steps ;) Glad it worked for you :)

aelinuxguy wrote:
Spektr,

Thanks for this information! I always wanted some way to easily respawn MythFrontend when it crashes. For what it's worth, I did not even really want the dialog asking whether or not to restart the frontend (I was content with the frontend restarting immediately after pressing GO), so I modified restartmyth.sh to be just this:

Code:
#!/bin/sh

killall mythfrontend
mythfrontend &


I'd also chopped down your .lircrc to just this

Code:
begin
   prog = irexec
   button = Go
   config = restartmyth.sh &
end


I suspect for anybody else out there that just wants this immediate respawning, the apt-get would not be neccessary and only the exec lines in the .fvwm2rc would be needed.


Top
 Profile  
 
PostPosted: Wed Oct 27, 2004 7:08 am 
Nice job Spektr!
But I don't want to change the focus options of KnoppMyth. I had problems with focus before (MythTV without KnoppMyth) and now I'm just glad it works. So I couldn't use your method, but I did want the functionality..
Next, I was a bit frightened that by implementing the script of aelinuxguy my girlfriend would keep restarting Mythfrontend accidentally.

So I made my own version! I wanted the frontend to restart only when the GO button is pushed TWICE within 3 seconds.

In /home/.fvwm/.fvwm2rc I added at the bottom:
Code:
exec irxevent &
exec irexec &


Then I changed /home/mythtv/.lircrc to add:
Code:
begin
   prog = irexec
   button = Go
   config = restartmyth.sh &
end


Till now nothing special.

Now the script: restartmyth.sh
Code:
#!/bin/bash

FirstClickFile="/home/mythtv/.FirstClick"
maxClickTime=3

FirstClick() {
 date > $FirstClickFile
 # echo DEBUG: FirstClick!
 exit
}

SecondClick() {
 # If the time between the first and the second click was less than $maxClickTime, restart mythfrontend
 timeSinceLastClick=$(expr $(date +"%G%m%d%H%M%S") - $(date -f /home/mythtv/.FirstClick +"%G%m%d%H%M%S"))

 if [ "$timeSinceLastClick" -lt "$maxClickTime" ]; then
  # echo DEBUG: SecondClick!
  killall mythfrontend
  mythfrontend &
 else
  FirstClick
 fi

 rm -f $FirstClickFile
 exit
}

[ -f "$FirstClickFile" ] || FirstClick
SecondClick

Put restartmyth.sh somewhere in the path (cp restartmyth.sh /usr/bin) and change the permissions (chmod 777 /usr/bin/restartmyth.sh).

As you can see it only restarts Mythfrontend when it's run twice within 3 seconds (A doubleclick on the GO button on the remote). This enables me to restart mythfontend without changing the focus settings, and my girlfriend can't by accident restart it.

I hope this is also usefull to someone else!

Good luck!


Top
  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 7:59 am 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
Spektr wrote:
but you still DO need to install lirc-x to get irxevent and irexec, from what I could find they aren't install on knopppmyth by default.
Are you certain?

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 11:12 am 
I did it without the apt-get thing and it works great!


Top
  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 3:38 pm 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
mjvdvlugt wrote:
I did it without the apt-get thing and it works great!
I wonder why?! :)

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 9:03 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
cesman wrote:
mjvdvlugt wrote:
I did it without the apt-get thing and it works great!
I wonder why?! :)

My guess would be because some terribly clever knoppmyth developer already included it? Did I guess right? ;-)

On my system with no apt-get::
Code:
root@black:/home/mythtv # locate irexec irxevent
/usr/local/bin/irexec
/usr/local/man/man1/irexec.1
/usr/local/bin/irxevent
/usr/local/man/man1/irxevent.1

Yay!!! I guessed right!!! ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 27, 2004 11:49 pm 
Offline
Joined: Mon Jan 26, 2004 2:07 pm
Posts: 32
I was too lazy to search for it, and I guess /usr/local/bin wasn't in my path or something, because I wasn't able to find it. In any event, there's no problem with being thorough, I say ;)

On another note cesman, perhaps adding some version of this script to knoppmyth would help. I know the biggest problem I see in mythtv's design is that if the frontend dies and you have no keyboard (and no script such as this)...then you are left to reboot, or ssh in (which only a technical person could do). Just an idea ;)

cesman wrote:
Spektr wrote:
but you still DO need to install lirc-x to get irxevent and irexec, from what I could find they aren't install on knopppmyth by default.
Are you certain?


Last edited by Spektr on Wed Oct 27, 2004 11:56 pm, edited 1 time in total.


Top
 Profile  
 
PostPosted: Wed Oct 27, 2004 11:53 pm 
Offline
Joined: Mon Jan 26, 2004 2:07 pm
Posts: 32
No problem, I like to contribute. Nice job on your script too. Just a few comments...First, as to focus method...the method I use is fully tested and works great...I actually use FVWM for my full-time window manager (http://www.malevolent.net/ss.png for a screenshot of my desktop if you are curious), so I have gotten to know it intimately ;)

Also, you may just want to chown your restartmyth script to mythtv:root and set perms to 774, just to be secure ;)

Cheers

mjvdvlugt wrote:
Nice job Spektr!
But I don't want to change the focus options of KnoppMyth. I had problems with focus before (MythTV without KnoppMyth) and now I'm just glad it works. So I couldn't use your method, but I did want the functionality..
Next, I was a bit frightened that by implementing the script of aelinuxguy my girlfriend would keep restarting Mythfrontend accidentally.

So I made my own version! I wanted the frontend to restart only when the GO button is pushed TWICE within 3 seconds.

In /home/.fvwm/.fvwm2rc I added at the bottom:
Code:
exec irxevent &
exec irexec &


Then I changed /home/mythtv/.lircrc to add:
Code:
begin
   prog = irexec
   button = Go
   config = restartmyth.sh &
end


Till now nothing special.

Now the script: restartmyth.sh
Code:
#!/bin/bash

FirstClickFile="/home/mythtv/.FirstClick"
maxClickTime=3

FirstClick() {
 date > $FirstClickFile
 # echo DEBUG: FirstClick!
 exit
}

SecondClick() {
 # If the time between the first and the second click was less than $maxClickTime, restart mythfrontend
 timeSinceLastClick=$(expr $(date +"%G%m%d%H%M%S") - $(date -f /home/mythtv/.FirstClick +"%G%m%d%H%M%S"))

 if [ "$timeSinceLastClick" -lt "$maxClickTime" ]; then
  # echo DEBUG: SecondClick!
  killall mythfrontend
  mythfrontend &
 else
  FirstClick
 fi

 rm -f $FirstClickFile
 exit
}

[ -f "$FirstClickFile" ] || FirstClick
SecondClick

Put restartmyth.sh somewhere in the path (cp restartmyth.sh /usr/bin) and change the permissions (chmod 777 /usr/bin/restartmyth.sh).

As you can see it only restarts Mythfrontend when it's run twice within 3 seconds (A doubleclick on the GO button on the remote). This enables me to restart mythfontend without changing the focus settings, and my girlfriend can't by accident restart it.

I hope this is also usefull to someone else!

Good luck!
[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 28, 2004 12:09 am 
Offline
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location: Fontana, Ca
If the frontend or backend dies, it is dying for a reason. While your's is a good idea, it is best to investigate why the death has occured first before restarting the process.

_________________
cesman

When the source is open, the possibilities are endless!


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ] 
Go to page 1, 2, 3  Next



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 5 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