#!/bin/sh
#
# keybdev - program to remap external usb keyboard to US/AU layout
# version 0.0.2
#
# Copyright (C) 2005 hdluc@yahoo.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
######################################################################
. /etc/hotplug/hotplug.functions

make_remover ()
{
cat > /etc/hotplug/usb/keybdev.off << EOF
#!/bin/sh
# This file is generated by keybdev
#. /etc/hotplug/hotplug.functions
/usr/X11R6/bin/xmodmap /etc/X11/kb/spitz.xmodmap
/usr/X11R6/bin/xset r on
EOF

chmod 755 /etc/hotplug/usb/keybdev.off
}

add_remover ()
{
    if [ ! -f $REMOVER ]; then
      ln -s /etc/hotplug/usb/keybdev.off $REMOVER
    fi
}

# start execution here
if [ ! -f /etc/hotplug/usb/keybdev.off ]; then
    make_remover
fi
if [ -f "/proc/bus/usb/drivers" ] && [ "`grep keyboard /proc/bus/usb/drivers`" != "" ]; then
    /usr/X11R6/bin/xmodmap /etc/X11/kb/usb.xmodmap
    /usr/X11R6/bin/xset r off
    add_remover 
fi
