Skip to content

Instantly share code, notes, and snippets.

@h4cc
Created July 14, 2014 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save h4cc/61734456d7bc760b13f0 to your computer and use it in GitHub Desktop.
Save h4cc/61734456d7bc760b13f0 to your computer and use it in GitHub Desktop.
Script for rotating the screen on my Thinkpad X200T.
#!/bin/sh
# 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.
case "$rotation" in
normal)
# rotate to the left
xrandr -o left
xsetwacom set "Serial Wacom Tablet stylus" rotate ccw
xsetwacom set "Serial Wacom Tablet eraser" rotate ccw
xsetwacom set "TPPS/2 IBM TrackPoint" rotate ccw
;;
left)
# rotate to inverted
xrandr -o inverted
xsetwacom set "Serial Wacom Tablet stylus" rotate half
xsetwacom set "Serial Wacom Tablet eraser" rotate half
xsetwacom set "TPPS/2 IBM TrackPoint" rotate half
;;
inverted)
# rotate to the right
xrandr -o right
xsetwacom set "Serial Wacom Tablet stylus" rotate cw
xsetwacom set "Serial Wacom Tablet eraser" rotate cw
xsetwacom set "TPPS/2 IBM TrackPoint" rotate cw
;;
right)
# rotate to normal
xrandr -o normal
xsetwacom set "Serial Wacom Tablet stylus" rotate none
xsetwacom set "Serial Wacom Tablet eraser" rotate none
xsetwacom set "TPPS/2 IBM TrackPoint" rotate none
;;
esac
@antiguru
Copy link

I created a slightly improved variant, to be found on https://gist.github.com/antiguru/3cb11dc5f92a4ebd115d. Thanks for providing the script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment