Skip to content

Instantly share code, notes, and snippets.

@lexszero
Created October 25, 2019 19:40
Show Gist options
  • Save lexszero/91a61f270d6b560763a6024d492bffe0 to your computer and use it in GitHub Desktop.
Save lexszero/91a61f270d6b560763a6024d492bffe0 to your computer and use it in GitHub Desktop.
#!/bin/bash
xi_dev_id() {
xinput | sed -n "s/.*$1.*id=\\([0-9]\\+\\).*/\1/p"
}
xi_prop_id() {
xinput list-props $1 | sed -n "s/.*$2.*(\\([0-9]\\+\\).*/\1/p"
}
xi_prop_get() {
xinput list-props $1 | sed -n "s/.*$2.*\t\(.*\)$/\1/p"
}
xi_prop_set() {
local propid=`xi_prop_id $1 "$2"`
xinput set-int-prop $1 $propid 8 $3
}
deven='Device Enabled'
touchpad=`xi_dev_id Synaptics`
trackpoint=`xi_dev_id TrackPoint`
set_stat() {
local newstat=$1
echo "newstat=$newstat"
xi_prop_set $touchpad "$deven" $(((newstat & 2) >> 1))
xi_prop_set $trackpoint "$deven" $((newstat & 1))
}
case $1 in
none)
set_stat 0
;;
trackpoint)
set_stat 1
;;
touchpad)
set_stat 2
;;
both)
set_stat 3
;;
toggle)
stat=$(((`xi_prop_get $touchpad "$deven"` << 1) |`xi_prop_get $trackpoint "$deven"`))
echo "stat=$stat"
set_stat $(((stat + 1) % 4))
;;
*)
echo "Usage: ${0##*/} none|trackpoint|touchpad|both|toggle"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment