Skip to content

Instantly share code, notes, and snippets.

@n1trux
Last active May 21, 2017 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1trux/491c52d547d746d8dbdbacb92e97a287 to your computer and use it in GitHub Desktop.
Save n1trux/491c52d547d746d8dbdbacb92e97a287 to your computer and use it in GitHub Desktop.
x230 tablet scripts for rotating screen and disabling ultranav touchpad/trackpoint
#!/bin/bash
# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation.
rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"
# Using current screen orientation proceed to rotate screen and input devices.
# find the names for devices with xinput --list
case "$rotation" in
inverted)
# rotate to the left
xrandr -o left
xsetwacom set 'Wacom ISDv4 E6 Pen stylus' rotate ccw
xsetwacom set 'Wacom ISDv4 E6 Pen eraser' rotate ccw
xsetwacom set 'Wacom ISDv4 E6 Finger touch' rotate ccw
xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
;;
right)
# rotate to inverted
xrandr -o inverted
xsetwacom set 'Wacom ISDv4 E6 Pen stylus' rotate half
xsetwacom set 'Wacom ISDv4 E6 Pen eraser' rotate half
xsetwacom set 'Wacom ISDv4 E6 Finger touch' rotate half
xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
;;
normal)
# rotate to the right
xrandr -o right
xsetwacom set 'Wacom ISDv4 E6 Pen stylus' rotate cw
xsetwacom set 'Wacom ISDv4 E6 Pen eraser' rotate cw
xsetwacom set 'Wacom ISDv4 E6 Finger touch' rotate cw
xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
;;
left)
# rotate to normal
xrandr -o normal
xsetwacom set 'Wacom ISDv4 E6 Pen stylus' rotate none
xsetwacom set 'Wacom ISDv4 E6 Pen eraser' rotate none
xsetwacom set 'Wacom ISDv4 E6 Finger touch' rotate none
xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop 'TPPS/2 IBM TrackPoint' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
;;
esac
#!/bin/bash
ENABLED=`xinput list-props 'SynPS/2 Synaptics TouchPad' | sed -n 's/\sDevice Enabled.*:\s\([0,1]\)/\1/p'`
if [ $ENABLED -eq 1 ]
then
xinput disable 'SynPS/2 Synaptics TouchPad';
xinput disable 'TPPS/2 IBM TrackPoint'
else
xinput enable 'SynPS/2 Synaptics TouchPad';
xinput enable 'TPPS/2 IBM TrackPoint'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment