Skip to content

Instantly share code, notes, and snippets.

@powerswitch
Created November 12, 2013 16:25
Show Gist options
  • Save powerswitch/7433869 to your computer and use it in GitHub Desktop.
Save powerswitch/7433869 to your computer and use it in GitHub Desktop.
/usr/bin/xrotate rotate X-Screen and Wacom
#!/bin/bash
echo "xrotate screen"
output=LVDS1
if [ "$XROT_OUTPUT" ]
then
output=$XROT_OUTPUT;
fi
geomnbr=0
xrandr=normal
wacom=normal
xmm=normal
if [ "$1" == "-" ] || [ "$1" == "+" ] || ! [ "$1" ];
then
operator="$1";
[ "$1" ] || operator='+';
case `xrandr --verbose | grep "^$output " | sed "s/^[^ ]* [^ ]* [^ ]* ([^(]*) \([a-z]*\).*/\1/"` in
normal) geom=0;;
left) geom=1;;
inverted) geom=2;;
right) geom=3;;
esac
let geom=${geom}${operator}1+4
let geom=${geom}%4
else
geom="$1"
fi
case $geom in
1) wacom=CCW; xrandr=left; xmm=ccw ;;
2) wacom=HALF; xrandr=inverted; xmm=half ;;
3) wacom=CW; xrandr=right; xmm=cw ;;
*) wacom=NONE; xrandr=normal; xmm=none ;;
esac
echo "xrandr to $xrandr, xsetwacom to $wacom" >&2
if xrandr --output "$output" --rotate "$xrandr"; then
xmodmap /home/simon/.Xmm_"$xmm"
for device in "Serial Wacom Tablet WACf004 stylus" "Serial Wacom Tablet WACf004 eraser" #$devices # CHANGE TO WHATEVER THE NAME OF YOUR WACOM IS
do
xsetwacom set "$device" Rotate "$wacom"
done
fi
#workaround for linuxwacom bug
if [ "`xsetwacom get stylus Mode`" == '1' ]; then
for decive in "Serial Wacom Tablet WACf004 stylus" "Serial Wacom Tablet WACf004 eraser"
do
xsetwacom set stylus CoreEvent "off"
xsetwacom set stylus Mode "off"
done
{ sleep 1;
for device in "Serial Wacom Tablet WACf004 stylus" "Serial Wacom Tablet WACf004 eraser"
do
xsetwacom set stylus Mode "on"
xsetwacom set stylus CoreEvent "on"
done; } &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment