Skip to content

Instantly share code, notes, and snippets.

@DennisLfromGA
Created August 20, 2014 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DennisLfromGA/95ecaa1b16d436a7ab6e to your computer and use it in GitHub Desktop.
Save DennisLfromGA/95ecaa1b16d436a7ab6e to your computer and use it in GitHub Desktop.
A shell script to get the Chromebook's touchpad status
### Script to get the status of the Trackpad device
#DEBUG=''
[[ -n "$DEBUG" ]] && set -x
TP=''
TPSTATE=''
TPSTATUS=''
#VERBOSE=''
## Get Trackpad ID number from Crosh
#+ Write a custom crosh script to get the trackpad id number
echo "crosh <<ENDCROSH
inputcontrol --names
exit
ENDCROSH" 2>&1 >/tmp/cr-gettpid.sh
#+ Run the custom crosh script to get the trackpad id number
sh /tmp/cr-gettpid.sh 2>&1 > /tmp/tp.id
TP=`grep -i trackpad /tmp/tp.id | cut -d : -f1`
[[ -n "$VERBOSE" ]] && echo -n "Trackpad ID is $TP"
## Get Trackpad status and report it
TPSTATUS="`/opt/google/touchpad/tpcontrol status| awk \"/^DEVICE: $TP/{c=3}c&&c--\" | tail -n 1 | awk '{ print $NF }'`"
if [ "$TPSTATUS" = 0 ]; then TPSTATE='OFF'; else TPSTATE='ON'; fi
[[ -n "$VERBOSE" ]] && echo " and shoud be $TPSTATE now..."
[[ -n "$DEBUG" ]] && set +x
exit $TPSTATUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment