#!/bin/sh
. /etc/profile
. /etc/systemconfig

#keylaunch &
#/usr/bin/tilda &

/usr/X11R6/bin/unclutter -root -idle 0 -jitter 400 -noevents  &
/usr/bin/xvattr -a XV_COLORKEY -v 0
mtd &
#/usr/bin/nvidia-settings -l
#/usr/bin/nvidia-settings -a InitialPixmapPlacement=2

if [ x$ShowTips = "x1" ]
then
    echo "Alt+h for help"  | osd_cat --font="-adobe-helvetica-bold-*-*-*-34-*-*-*-*-*-*-*" --shadow=3 --pos=middle --align=centre --offset=200 --color=yellow --delay=5 &
fi


if [ !  $SystemType = "Frontend_only" ]
then
  if [  -f ~/.configure ]
  then
        sudo -E tweaker.pl
    	/bin/rm /tmp/fps # ??? clean up a temp file that will eventually be obsolete anyway
        sudo sv stop mythbackend
        xterm -fn *18* -e sudo taskset -c 0 /usr/bin/mythtv-setup
        sudo sv start mythbackend
		sudo chown -R mythtv.mythtv /home/mythtv
        nice -n 19 mythfilldatabase --quiet &
        rm ~/.configure
   fi
fi


if [ x"$UseMythWelcome" = "x1" ]
then
        STARTCMD="/usr/bin/mythwelcome"
else
        STARTCMD="/usr/bin/mythfrontend -d -l /var/log/mythtv/mythfrontend.log"
fi

echo "====================================================================="
echo "Starting $STARTCMD"
firstboot.sh &

        if [ -f /tmp/nomfe ]
        then
		   exit 0
        else
           if [ -f /tmp/debug ]
           then
                echo "using gbd/debug"
                gdb /usr/bin/mythfrontend -x $MV_ROOT/mfegdbcommands.txt
                mv gdb.txt gdb.txt.mythfrontend
                sleep 10
            else
                killall -9 irexec
                /usr/bin/irexec &
                $STARTCMD 2>&1
           fi
        fi