One other item that I did not see at first:
Code:
elif [[ $new == "4" ]]; then
should be:
Code:
elif [[ $new == "1" ]]; then
when you are checking for /sys/devices/platform/tablet.