#!/bin/sh

SPLASH=false
VERBOSE=true

for x in $(cat /proc/cmdline); do
        case $x in
        splash*)
                SPLASH=true;
                ;;
        quiet*)
                VERBOSE=false
                ;;
        esac
done

[ "$SPLASH" != "true" ] || pidof usplash >/dev/null && exit 1

[ -f /etc/usplash.conf ] && . /etc/usplash.conf

# Clean up the console before we switch to it, to avoid text flicker:
if [ -x /usr/bin/tput ]; then
	tput -Tlinux reset > /dev/tty8
fi

# Run usplash, switching to vt8
if [ $VERBOSE = "true" ]; then
	varg=-v
else
	varg=
fi
if [ "$xres" ] && [ "$xres" != 0 ] && [ "$yres" ] && [ "$yres" != 0 ]; then
	/sbin/usplash -c -x "$xres" -y "$yres" $varg &
else
	/sbin/usplash -c $varg &
fi

# Append our PID to the list of processes that sendsigs won't kill,
# to avoid flicker on shutdown:
echo $! >> /var/run/sendsigs.omit

# Sleep hack to wait for us to be ready, only needed until usplash/bogl
# can be properly daemonised:
sleep 1

# Just because, tidyness is next to... Something or other:
exit 0
