Battling with a terribly designed HP 4520s (oh for a Thinkpad), I had enough of hitting the stupid touchpad accidentally when typing. The following will turn the touchpad on and off accordingly. The script comes with no warranty, use at your own risk:
#!/bin/bash
#
# Turn that pesky touchpad on and off
#
# ----------------------------------------------------------------------------
id=`xinput list | grep TouchPad | awk '{print $6}' | sed 's/id=//'`
if [ $1 = 'on' ]; then
xinput set-prop $id "Device Enabled" 1
else
xinput set-prop $id "Device Enabled" 0
fi