#!/bin/sh

for ID in $(xinput list | \
                grep Wacom | \
                grep -Eo '\s*id\=[0-9]{1,2}' | \
                grep -Eo '[0-9]{1,2}') ; do
    STATE=$(xinput list-props $ID | \
                grep 'Device Enabled' | \
                awk '{print $4}')
    if [ $STATE -eq 1 ]
    then
        xinput disable $ID
        echo "Touchscreen disabled."
    else
        xinput enable $ID
        echo "Touchscreen enabled."
    fi
done
