#!/bin/sh

# $Progeny: xinitrc,v 1.8 2002/04/15 20:29:23 branden Exp $

BITMAP=$LIVE/share/installer/root_window.xbm
INSTALLER=$LIVE/share/installer/installer-druid
INSTALLER_GLADE=$LIVE/share/installer/installer.glade

# show people a cursor that tells them to be patient
xsetroot -cursor_name watch

# set the root window

if xsetroot -solid darkslateblue; then
    echo "Set root window to solid darkslateblue." >&2
else
    echo "Can't set the root window to a solid color!  What's going on?" >&2
fi

# XXX: pretty kludgey...
FALLBACK=yes
DEPTH=$(xdpyinfo | grep 'depth of root window' | cut -d: -f2 | sed -e 's/ //g' -e 's/planes//')
if [ -n "$DEPTH" ]; then
    if [ $DEPTH -gt 4 ]; then
        IMAGEFILE=$(ls $LIVE/share/installer/root_window.* | grep -v '\.xbm$' | head -1)
        if [ -n "$IMAGEFILE" ]; then
            if xsetbg $IMAGEFILE; then
                echo "Using $IMAGEFILE as root window." >&2
                FALLBACK=
            fi
        fi
    fi
fi

if [ -n "$FALLBACK" ]; then
    if [ -e $BITMAP ]; then
        if xsetroot -bitmap $BITMAP; then
            echo "Using $BITMAP as root window." >&2
            FALLBACK=
        fi
    fi
fi

if [ ! -x $INSTALLER ]; then
    xmessage -center -buttons "OK:0" "$INSTALLER is not executable."
fi

if [ ! -e $INSTALLER_GLADE ]; then
    xmessage -center -buttons "OK:0" "$INSTALLER_GLADE does not exist."
fi

python $INSTALLER $INSTALLER_GLADE

echo $? > $STATUSFILE

# xinit throws away our exit status anyway
exit 0

# vim:ai:et:sts=4:sw=4:tw=0:
