restart mythfrontend using your remote control and irexec

mythfrontend sometimes freezes on me. So I configured a button on my remote control to enable me to kill mythfrontend and restart it. This is really useful especially if you don’t have a keyboard and mouse plugged into your machine all the time or if you just want to make it all wife friendly. Here’s how I did it on my Fedora Core 12 mythtv frontend.

First of all – I’m assuming you already have your remote control working under lircd.

Second of all I used this guide to get me started –>

But I found it didn’t quite work for me, so I modified it a little.

First I created the script similar to the guide above in my mythtv user local bin directory (in my case /home/mythtv/bin/) and called it

# script to restart mythfrontend
for x in `ps -C mythfrontend | grep -v PID` end; do
test $x != 'mythfrontend' && continue
if [ $RUNNING = 1 ]; then
`killall mythfrontend`
`mythfrontend &`

Next I created an entry in my .lircrc file to run irexec. irexec is used to run programs when a particular button is pressed on your remote – in my case I wanted the Power button on my remote to run the script above when pressed – this is defined in the .lircrc file and in my case it is stored under /home/mythtv/.lircrc – yours might be somewhere esle depending on your setup. Go here to read more about irexec –>

prog = irexec
remote = mceusb
button = Power
config = /home/mythtv/bin/ &

Now you need to setup your session to run up irexec when you log in or the server starts up. This is done whilst logged into the user you run mythfrontend as. In my case I have gnome installed so I just go to “System” –> “Perferences” –> “Startup Applications” on the gnome display. You should get something like this (mine is a little cut-off):

Startup Application Perferences

Press “Add” and fill in the name as “irexec” or anything you want really; command as “/usr/local/bin/irexec -d /home/mythtv/.lircrc”; put in a comment if you like or not; then press “Add”. This should now startup irexec when your session starts up.

I suggest you now give your machine a reboot and test it – you might want to check whether your mythbackend is recording anything before you reboot otherwise you will interrupt your recordings. Also if you haven’t already, your might find it easier to setup Fedora to auto login at startup – I’ve written a guide here.

Once rebooted you should be able to press the power button on your remote once to kill mythfrontend and again to start it back up again. That’s it. I welcome comments, feedback and suggestions to make this better or easier.