#!/bin/sh
# A script to apply the changes made to xorg.conf
# Part of the Puppy XkbConfigurator

##--------variables---------->>
INFILE="/etc/X11/xorg.conf"

#get all parameters
MODEL=`fgrep '"XkbModel"' $INFILE | grep -v '^#' | cut -d'"' -f4`
LAYOUT=`fgrep '"XkbLayout"' $INFILE | grep -v '^#' | cut -d'"' -f4`
VARIANT=`fgrep '"XkbVariant"' $INFILE | grep -v '^#' | cut -d'"' -f4`
OPTIONS=`fgrep '"XkbOptions"' $INFILE | grep -v '^#' | cut -d'"' -f4`

#debug option
#echo "model is |$MODEL| ; layout is |$LAYOUT| ; variant is |$VARIANT| ; options are |$OPTIONS|"

# create the command to execute
COMMAND="setxkbmap -rules xorg -model $MODEL -layout \"$LAYOUT\" -variant \"$VARIANT\" -option \"$OPTIONS\" "

#execute command
eval "$COMMAND"
if [ $? -eq 0 ];then
	case "$LAYOUT" in *,*) 
	  pidof fbxkb >/dev/null || ( which fbxkb >/dev/null && fbxkb & ) ;;
	esac
	eval $SUCCESS
else
	eval $ERRMSG
fi
exit