Skip to content

Instantly share code, notes, and snippets.

@antiguru
Forked from h4cc/rotate.sh
Last active September 23, 2018 09:24
Show Gist options
  • Save antiguru/3cb11dc5f92a4ebd115d to your computer and use it in GitHub Desktop.
Save antiguru/3cb11dc5f92a4ebd115d to your computer and use it in GitHub Desktop.
Lenovo X220 Tablet rotation script (sets rotation, wacom rotation, subpixel rendering)
#!/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)')"
# Find input devices to be rotated.
IFS=$'\n'
devices=("$(xinput --list --name-only | egrep '(Wacom)|(TrackPoint)')")
rotate() {
xrandr -o $1
for device in $devices; do
xsetwacom set $device rotate $2
done;
gconftool-2 -s /desktop/gnome/font_rendering/rgba_order -t $3
}
# Using current screen orientation proceed to rotate screen and input devices.
case "$rotation" in
normal)
# rotate to the left
rotate left ccw vbgr
;;
left)
# rotate to inverted
rotate inverted half bgr
;;
inverted)
# rotate to the right
rotate right cw vrgb
;;
right)
# rotate to normal
rotate normal none rgb
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment