Skip to content

Instantly share code, notes, and snippets.

@mxey
Created January 28, 2011 07:59
Show Gist options
  • Select an option

  • Save mxey/799977 to your computer and use it in GitHub Desktop.

Select an option

Save mxey/799977 to your computer and use it in GitHub Desktop.
#!/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