#!/bin/bash

# Comprobamos si el equipo tiene TouchScreen:
MENSAJE="No se ha detectado ninguna Wacom en el equipo ..."
! ( xinput | grep "Wacom" > /dev/null 2>&1 ) && echo "${MENSAJE}"

# Activamos o desactivamos según el parámetro recibido:
if test -z "${1}" ; then
  echo "Debes indicar como parámetro \"on\" u \"off\""
  exit 1
fi

case "${1}" in
  "on" )
    xinput | grep "Wacom" | grep -Po 'id=\d+' | cut -d"=" -f2 | xargs -i xinput enable {}
    ;;
  "off" )
    xinput | grep "Wacom" | grep -Po 'id=\d+' | cut -d"=" -f2 | xargs -i xinput disable {}
    ;;
  * )
    echo "Debes indicar como parámetro \"on\" u \"off\""
    ;;
esac
exit 0
