Created
July 17, 2014 20:26
-
-
Save GrooveStomp/702d2a784a939dcc8cbc to your computer and use it in GitHub Desktop.
touchpad enable/disable with autocomplete
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
| # ~/.bash.d/touchpad.sh | |
| touchpad () | |
| { | |
| echo "WARNING: This script is currently hardware-specific."; | |
| echo " You should only use this on the Dell XPS 13."; | |
| local arg=$1; | |
| local touchpad_id=$(xinput list | grep Trackpad | sed 's/^.*id=//' | sed -re 's/[[:space:]]+.*//'); | |
| case $arg in | |
| info) | |
| xinput list | grep --line-buffered Trackpad | |
| ;; | |
| enable) | |
| xinput set-prop ${touchpad_id} "Device Enabled" 1 | |
| ;; | |
| disable) | |
| xinput set-prop ${touchpad_id} "Device Enabled" 0 | |
| ;; | |
| esac | |
| } | |
| # ~/.bash.d/completions/touchpad.sh | |
| _touchpad() { | |
| local cur prev opts | |
| COMPREPLY=() | |
| cur="${COMP_WORDS[COMP_CWORD]}" | |
| prev="${COMP_WORDS[COMP_CWORD-1]}" | |
| opts="info enable disable" | |
| case "${prev}" in | |
| file) | |
| COMPREPLY=( $(compgen -f ${cur}) ) | |
| return 0 | |
| ;; | |
| hostname) | |
| COMPREPLY=( $(compgen -A hostname ${cur}) ) | |
| return 0 | |
| ;; | |
| *) | |
| ;; | |
| esac | |
| COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
| } | |
| complete -F _touchpad touchpad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment