#!/bin/bash
#
# This is a little hotplug script that disables the Touchpad when
# you plug in a usb mouse and reenables it when the mouse is unplugged.
#
# Simply put this into /etc/hotplug/usb/usbhid and thats it...

SYNCLIENT=/usr/bin/synclient

check_for_usb_mouse () {
	if [ "`grep -e Mouse /proc/bus/usb/devices`" ]; then
		$SYNCLIENT TouchpadOff=1
	else
		$SYNCLIENT TouchpadOff=0
	fi
}


add_device () {
	ln -s /etc/hotplug/usb/usbhid $REMOVER
	check_for_usb_mouse
}


remove_device () {
	rm $REMOVER
	check_for_usb_mouse
}

case $ACTION in

add)
	add_device
	;;
remove)
	remove_device
	;;
*)
	;;

esac

exit 0
