#!/bin/sh
#
# This script sets the keyboard layout for user session using the X Keyboard Extension
#
# Examples $HOME/.xkb:
# LAYOUT="us,ru"
# MODEL="thinkpad"
# VARIANT=",winkeys"
# OPTION="grp:caps_toggle,grp_led:scroll"
#
# Author:	Valery V. Inozemtsev <shrek@altlinux.org>
#

SETXKBMAP=/usr/X11R6/bin/setxkbmap
if [ -x "$SETXKBMAP" -a -r $HOME/.xkb ]; then

# Reset parameters.
LAYOUT=
MODEL=
VARIANT=
OPTION=
PARAMS=

. $HOME/.xkb

[ -z "$LAYOUT" ] || PARAMS="-layout '$LAYOUT'"
[ -z "$MODEL" ] || PARAMS="$PARAMS -model '$MODEL'"
[ -z "$VARIANT" ] || PARAMS="$PARAMS -variant '$VARIANT'"
[ -z "$OPTION" ] || PARAMS="$PARAMS -option -option '$OPTION'"

[ -z "$PARAMS" ] || eval $SETXKBMAP $PARAMS 2>/dev/null

fi