#! /bin/sh

PREREQ=""
DESCRIPTION="Setting up system keymap"

[ -r /scripts/casper-functions ] && . /scripts/casper-functions

prereqs()
{
       echo "$PREREQ"
}

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

log_begin_msg "$DESCRIPTION"

# commandline
for x in $(cat /proc/cmdline); do
    case $x in
	keymap=*)
	    keymap=${x#keymap=}
	    set_keymap="true"
	    ;;
    esac
done

if [ "${set_keymap}" ]; then
	sed -i -e "s|qwerty/us|qwerty/${keymap}|" \
		"${rootmnt}/etc/conf.d/keymaps"
fi

# Setup keymap for lightdm.
if [ -r "${rootmnt}/etc/lightdm.conf" ]; then
	sed -i -e "s|^\#\(layout=\).*|\1${keymap}|" ${rootmnt}/etc/lightdm.conf
fi

log_end_msg
