Created
January 28, 2011 07:59
-
-
Save mxey/799977 to your computer and use it in GitHub Desktop.
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
| #!/bin/sh -e | |
| is_enabled () { | |
| local device="$1" | |
| s=$(xinput --list-props "$device" | fgrep 'Device Enabled' | egrep -o '[01]$') | |
| if [ "${s}" = "1" ]; then | |
| return 0 # enabled | |
| elif [ "${s}" = "0" ]; then | |
| return 1 # disabled | |
| else | |
| echo Pointer status unknown! >&2 | |
| exit 1 | |
| fi | |
| } | |
| set_status () { | |
| local device="$1" | |
| local status="$2" | |
| xinput --set-prop "${device}" 'Device Enabled' "${status}" | |
| } | |
| case "$(hostname -f)" in | |
| reaver.mxey.lan) | |
| device='Logitech USB-PS/2 Optical Mouse' | |
| ;; | |
| *) | |
| echo Unknown host! >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| if is_enabled "$device"; then | |
| set_status "$device" 0 | |
| else | |
| set_status "$device" 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment