Skip to content

Instantly share code, notes, and snippets.

@efruchter
Last active December 23, 2015 01:58
Show Gist options
  • Save efruchter/6563508 to your computer and use it in GitHub Desktop.
Save efruchter/6563508 to your computer and use it in GitHub Desktop.
display rotate script for Thinkpad x200 using xrandr, xsetwacom, and xbindkeys.
"bash rotate_display flip"
m:0x0 + c:161
NoSymbol

Rotation HotKey

You can also make the special rotation key work using xbinkeys. Just copy the rc file into your home dir. You'll need to add xbindkeys to your startup routine.

Use the auto snippet tool to get keycodes:

xbinkeys -k
#!/bin/bash
# config
output="LVDS1"
# get current rotation
current=`xrandr -q --verbose|grep LVDS1|cut -d ' ' -f6`
case $current in
normal) geom=0;;
left) geom=1;;
inverted) geom=2;;
right) geom=3;;
esac
if [ "$1" == "flip" ] || [ "$1" == "rotate" ];
then
# based on current rotation set new rotation
if [ "$1" == "flip" ];
then
# flip
if [ "$geom" == "0" ];
then
wacom=cw
xrandr=right
else
wacom=none
xrandr=normal
fi
else
# rotate
case $geom in
0) wacom=cw; xrandr=right;;
3) wacom=half; xrandr=inverted;;
2) wacom=ccw; xrandr=left;;
1) wacom=none; xrandr=normal;;
esac
fi
echo "xrandr to $xrandr, xsetwacom to $wacom" >&2
# rotate display
xrandr -o $xrandr
# rotate wacom
xsetwacom set "13" Rotate $wacom
xsetwacom set "14" Rotate $wacom
xsetwacom set "15" Rotate $wacom
else
echo "possible parameters: flip, rotate"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment