#!/bin/sh
# If classmate-tools is installed and X isnt configured yet
# we assume that classmate-tools will be used and copy the
# matching config in place.

PREREQ=""
DESCRIPTION="Configuring X for classmate ..."

. /scripts/casper-functions

prereqs()
{
       echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
       prereqs
       exit 0
       ;;
esac

log_begin_msg "$DESCRIPTION"

if [ -e /root/etc/default/console-setup ];then
	. /root/etc/default/console-setup
fi

if [ -z "$XKBMODEL" ]; then
	XKBMODEL="pc105"
fi
if [ -z "$XKBLAYOUT" ]; then
	XKBLAYOUT="us"
fi

SOURCE=/root/usr/share/doc/classmate-tools/example-xorg.conf
TARGET=/root/etc/X11/xorg.conf
if  [ -e $SOURCE ] && [ ! -e $TARGET ]; then
            cp $SOURCE $TARGET
	    sed -i -e "s/\"XkbModel.*/\"XkbModel\"      \"$XKBMODEL\"/" $TARGET
	    sed -i -e "s/\"XkbLayout.*/\"XkbLayout\"     \"$XKBLAYOUT\"/" $TARGET
	    # why does that become executable ? the source file isnt ...
	    chmod -x $TARGET
fi

log_end_msg
