Here is another way of doing it where it will check to see if the device is floating or not:
Originally Posted by Favux
The xinput --list will list out the devices and the greps will look for a line that contains the N-Trig MultiTouch and floating slave words. If it finds a match, it means that touch is off. Otherwise touch is on.
# evdev touch toggle script
xinput --list|grep "N-Trig MultiTouch"|grep "floating slave" > /dev/null
if [ $TOUCH_ON -eq 1 ];then
xinput float "N-Trig Touchscreen"
xinput reattach "N-Trig Touchscreen" "Virtual core pointer"