[mythtv-users] Remotely restarting mythfrontend

Matthias Thyroff lists at thyroff.net
Tue Feb 13 00:19:51 UTC 2007


Am Montag, den 12.02.2007, 19:54 +0000 schrieb Stroller:
> On 12 Feb 2007, at 11:28, Matthias Thyroff wrote:
> > Am Montag, den 12.02.2007, 22:09 +1100 schrieb Sammo:
> >> Is it possible to ssh into a mythtv box and restart mythfrontend?
> >
> > I autostart the frontend with X; I can remotely restart X
> > (/etc/init.d/kdm restart), this does it.
> >
> > But I can also start and stop the frontend with the remote. ...
> >
> > In my lircrc I have
> >
> > # TV Button
> > begin
> > prog = irexec
> > button = TV
> > config = /usr/local/bin/mythtvbutton.sh
> > end
> >
> > and mythtvbutton.sh does
> >
> > #!/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
> >         echo 0 >> /tmp/mythtvbuttontest.txt
> >         ( $PROG & )
> >     else
> >         echo 1 >> /tmp/mythtvbuttontest.txt
> >         killall $PROG
> >     fi
> > fi
> > exit 0
> >
> > ******
> 
> If you'll excuse me for saying it, this seems like a rather  
> convoluted way of doing things.
> 
> You already state that `/etc/init.d/kdm restart` works for you, so  
> why do it any differently with lirc?
> 
> lirc's documentation <http://www.lirc.org/html/ 
> configure.html#lircrc_format> suggests that it can pass parameters to  
> programs, in this example "hello wold" is passed to `echo`:
> 
>      begin
>          remote = ANIMAX
>          button = MENU_DOWN
>          prog   = irexec
>          repeat = 0
>          config = echo "Hello world!"
>      end
> 
> So passing "start" to `/etc/init.d/kdm` should not be a problem, either:
> 
>      begin
>          prog   = irexec
>          button = TV
>          repeat = 0
>          config = /etc/init.d/kdm restart
>      end
> 
> Your solution and antani's both check MythTV's PID, but my distro's  
> init.d scripts already record the PID and make a note if it so that  
> they can kill the process when I run them with the "stop" or  
> "restart" parameter. I would rather leave PID management to them, as  
> in my experience distro's init scripts tend to be quite long and  
> comprehensive, handling case scenarios that I might have thought of  
> when hacking together a quick bash script. If kill the process &  
> start the program again manually it prevents them from doing their job.
> 
> Stroller.

Thanks for your input! For me, it seems pretty convenient to be able to
start and stop the frontend without restarting X; something else might
be running on it, too. Or maybe I just want to start xmms to play
instead of using mythmusic.

Btw, I think you got frontend and backend mixed up.

I have another cute script which checks if the frontend is running (you
know how); if not, it restarts the backend, which sometimes is
necessary, and it is using the init script. It is linked to the power
button on the remote, but by having me to stop the frontend first, it
prevents unintended backend restarts. 

My script (which isn't mine, I copied it from somewhere) doesn't look
for the PID; that expression returns 1 if the frontend runs, 0 if not.
Absulutely unnecessary, but, hey, it works! Won't overload the computer,
either.

Cheers

	Matthias





More information about the mythtv-users mailing list