Frontend Loading Script

From MythTV Official Wiki
Revision as of 18:23, 5 June 2008 by Craftyguy (talk | contribs) (Script)

Jump to: navigation, search

There are a few methods to load mythfrontend depending on your setup. This method uses a script that will continually reload mythfrontend if it ever crashes. While technically near impossible to guarantee that mythfrontend will stay running, it should rarely crash and it's more likely that someone will hit ESC too many times and we'll be left with an empty display on our big TV.

Script

To avoid having to break out the keyboard and restart mythfrontend, here's a little script I use to restart it automatically:

#!/bin/bash
# mythrestart.sh
# Automatically restart mythfrontend if it fails.

# Just for fun, lets start the myth transcode dameon, too.
sudo mtd -d

# Loop the call of mythfrontend.
while [ /bin/true ]
do
        sudo killall mythfrontend
        sudo mythfrontend
        sleep 2
done

Then, instead of starting Myth with 'mythfrontend', start it with the script above.


Alternate Script

Here is a different script I use to start mythfrontend and/or lircd if either quit/crash. The script is launched by irexec whenever I press the 'PC Power' button on my MCE remote.

It's also useful when you would like to start mythfrontend remotely (from SSH session for example), and having it forked to background.

#!/bin/sh
#startmythfrontend.sh
#Start mythfrontend and/or lircd on by remote button press from irexec

if [ "$LOGNAME" == "root" ]
then
        echo "Hello root, you should be running this script as \"mythtv\" user, goodbye."
        exit
fi


if [ ! "$(pidof mythfrontend)" ]
then
        echo "Mythfrontend is not started. Starting Mythfrontend..."
        DISPLAY=:0 xset -dpms
        DISPLAY=:0 mythfrontend > /var/log/mythfrontend.log 2>&1 &
else
        echo "Mythfrontend is already started."

fi


if [ ! "$(pidof irexec)" ]
then
        echo "Irexec is not started. Starting Irexec..."
        DISPLAY=:0 irexec -d /home/mythtv/.lircrc 2&> /home/mythtv/irexec.log 2>&1 &
else
        echo "Irexec is already started."
fi


Other Options

Another option is to have mythfrontend load automatically upon boot, this method is described at Frontend Auto Login