Last active
February 9, 2020 15:45
-
-
Save palevell/9b1952153c7e59f20296e5aaa6880a90 to your computer and use it in GitHub Desktop.
Creates BASH aliases for toggling laptop touch devices ON/OFF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# tpoff.sh v1.0.9 - Sunday, February 9, 2020 | |
# Create commands (aliases) to toggle touch devices ON/OFF | |
XINPUT=/usr/bin/xinput | |
if [ -x $XINPUT ]; then | |
DEVNAMES=() | |
DEVNAMES+=("Synaptics TouchPad") | |
DEVNAMES+=("AlpsPS/2 ALPS DualPoint TouchPad") | |
DEVNAMES+=("AlpsPS/2 ALPS DualPoint Stick") | |
LEN=${#DEVNAMES[@]} | |
i=0 | |
while [ $i -lt $LEN ]; do | |
DEVICE_ID=$($XINPUT --list |grep "${DEVNAMES[$i]}" |cut -d'=' -f2 |awk '{print $1}') | |
if [ ! -z $DEVICE_ID ]; then | |
OFF+="$XINPUT disable $DEVICE_ID; " | |
ON+="$XINPUT enable $DEVICE_ID; " | |
fi | |
(( i++ )) | |
done | |
if [[ ! -z $OFF ]]; then | |
alias tpoff="$OFF" | |
alias tpon="$ON" | |
fi | |
unset LEN OFF ON DEVICE_ID DEVNAMES | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment