#! /bin/sh

# make keyboard mapping table entry into configuration file keymaps.cfg
# #include generated table into source

name=$1
shortcut=`echo $name | sed -e "s,^\(..\).*,\1," | tr "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"`
shortcut=${2-$shortcut}
tablename="$name"
entry="$name	$tablename	$shortcut"

if egrep "^#*$entry" keymaps.cfg > /dev/null
then	echo "mapping already in keymaps.cfg"
elif	egrep "	$tablename	" keymaps.cfg > /dev/null
then	echo "mapping for this table already in keymaps.cfg"
else	echo "#$entry" >> keymaps.cfg
	echo "mapping added to keymaps.cfg (still disabled)"
	echo "check name and shortcut, enable and sort in manually"
fi

