[mythtv-users] Foolproof Mythbuntu start/restart irexec command

R. G. Newbury newbury at mandamus.org
Fri Aug 3 21:34:58 UTC 2012


On 08/03/2012 03:52 PM, Ian Evans wrote:

>
> So again, the logic for the script is "If it's it running, killall
> mythfrontend.real (so Mythbuntu then restarts it) and if it's not
> running at all start it." but I don't know how to write bash.

This is what I use:

############### startfrontend.sh script

#/!/bin/bash
export HOME=/home/mythtv/
export DISPLAY=:0.0
export PROG=mythfrontend

STATUS=0
# check for running mythfrontend
STATUS=`ps -ae | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`
export STATUS
#echo "STATUS = "$STATUS
if [ $STATUS -eq 0 ];
then
         # Start mythfrontend: play a tone to announce it is working
         /usr/bin/mplayer /usr/share/sounds/KDE-Im-Contact-In.ogg

         /usr/local/bin/mythfrontend --display $DISPLAY -v playback -l 
/var/log/mythfrontend.log &
         sleep 3
         killall startfrontend.sh;
else
        # kill all running mythfrontends: use different announcement tone
         /usr/bin/mplayer /usr/share/sounds/KDE-Im-Contact-Out.ogg
         killall mythfrontend
         killall startfrontend.sh;
fi
exit 0

########################

You need this stanza in your lircrc file:


# ******************   section needed in lircrc
# -------------- Begin section for irexec ------------------

# Red button on old remote
# Small 'power' button on Harmony remote, starts mythfrontend
begin
     prog = irexec
     button = KEY_EXIT
     repeat = 2
     config = /usr/local/sbin/startfrontend.sh
end
## -------------- End section for irexec --------------------

# *********************************************

You will have to fiddle around a little to find the right key name. The 
KEY_EXIT key here, is the small power key on the righthand side of a 
Logitech Harmony 330 *talking to an iMon remote receiver*. It's really 
the receiver which determines the output key-code you get from lirc, so 
you may have to play with irw or irrecord to see what keys map to in 
terms of their naming. In this case, you want the key to be mapped ONLY 
to irexec since it never gets 'focus' like an mplayer or mythtv screen 
instance.

And finally, you need to have irexec running
You can call the /usr/bin/irexec line in /etc/rc.d/rc.local or whatever 
runs last, In Fedora with systemd, there seem to be problems with that, 
so I just tacked the call into the bottom of the start{ stanza of 
/etc/rc.d.init.d/lirc so it is always called/started whenever the lirc 
service is started. (And I stop it in the stop{ stanza with a killall)


# ******************** section in rc.d/init.d/lirc
# bottom of start{ stanza
     /usr/bin/irexec -d /etc/lirc/lircrc
     return $retval
}

##################

Together this works like a charm.


HTH

Geoff


More information about the mythtv-users mailing list