Created
April 8, 2021 04:27
-
-
Save andreoss/76e02d095ed643ab80cf25f3df70bfec to your computer and use it in GitHub Desktop.
Toggle touchpad/trackpoint/mouse
This file contains 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
#!/bin/sh | |
set -u | |
list_all_ids() { xinput list --id-only; } | |
device_by_id() { xinput list --short "$1";} | |
device_property() { | |
xinput list-props "$1" | while read -r prop | |
do | |
case "$prop" in | |
*"$2"*:*[01]) | |
echo "${prop#*:}" | xargs | |
return 0 | |
;; | |
esac | |
done || (echo "unknown" && return 1) | |
} | |
enable_device() { xinput enable "$1";} | |
disable_device() { xinput disable "$1";} | |
toggle_device() { | |
case $(device_property "$1" "Device Enabled") in | |
1) | |
disable_device "$1" | |
;; | |
0) | |
enable_device "$1" | |
;; | |
esac | |
} | |
for id in $(list_all_ids) | |
do | |
case $(device_by_id "$id") in | |
*TrackPoint* | *Touchpad* ) | |
toggle_device "$id" | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment