Skip to content

Instantly share code, notes, and snippets.

@acarapetis
Created March 13, 2010 03:39
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 acarapetis/331086 to your computer and use it in GitHub Desktop.
Save acarapetis/331086 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# "Wacom Rotation" can be 0, 1, 2 or 3 where 1 is +90, 2 is -90 and 3 is 180 in degrees
# "Wacom ISDv4 E3" id=11
# "Wacom ISDv4 E3" eraser id=12
# "Wacom ISDv4 E3" id=13
#
# using device numbers of the stylus (10) or screen (12) is fragile as they can
# change however "Wacom ISDv4 E3" is not unique afaict
# Adjust these for your system:
STYLUS_CODE=11
ERASER_CODE=12
SCREEN_CODE=13
DIRFILE=$HOME/.current_direction
direction=$1
if [ $direction == next ]; then
if [ ! -e $DIRFILE ]; then
echo -n normal > $DIRFILE
fi
olddir=$( cat $DIRFILE )
case "$olddir" in
normal)
direction=left
;;
left)
direction=flipped
;;
flipped)
direction=right
;;
right)
direction=normal
;;
*)
direction=normal
;;
esac
fi
case "$direction" in
# For rotating the screen right
right )
xrandr --output LVDS1 --rotate right
xinput set-prop $STYLUS_CODE "Evdev Axis Inversion" 1, 1
# notice the size below is different than the tablet area
xinput set-prop $STYLUS_CODE "Evdev Axis Calibration" 1657, 0, 0, 2638
xinput set-prop $STYLUS_CODE "Evdev Axes Swap" 1
xinput set-prop $SCREEN_CODE "Wacom Rotation" 1
xinput set-prop $SCREEN_CODE "Wacom Tablet Area" 16320, 0, 0, 26112
echo -n right > $DIRFILE
;;
# Unsetting the input after choosing rotate right
# The order seems to be important
normal )
xrandr --output LVDS1 --rotate normal
xinput set-prop $STYLUS_CODE "Evdev Axis Inversion" 0, 0
# notice the size below is different than the tablet area
xinput set-prop $STYLUS_CODE "Evdev Axis Calibration" 0, 2638, 0, 1657
xinput set-prop $STYLUS_CODE "Evdev Axes Swap" 0
xinput set-prop $SCREEN_CODE "Wacom Rotation" 0
xinput set-prop $SCREEN_CODE "Wacom Tablet Area" 0, 0, 26112, 16320
echo -n normal > $DIRFILE
;;
# for choosing rotate left
left )
xrandr --output LVDS1 --rotate left
xinput set-prop $STYLUS_CODE "Evdev Axis Inversion" 0, 1
# notice the size below is different than the tablet area
xinput set-prop $STYLUS_CODE "Evdev Axis Calibration" 1657, 0, 2638, 0
xinput set-prop $STYLUS_CODE "Evdev Axes Swap" 1
xinput set-prop $SCREEN_CODE "Wacom Rotation" 2
#xinput set-prop $SCREEN_CODE "Wacom Tablet Area" # not necessary
echo -n left > $DIRFILE
;;
# for choosing upside down
flipped )
xrandr --output LVDS1 --rotate inverted
xinput set-prop $STYLUS_CODE "Evdev Axis Inversion" 1, 0
# notice the size below is different than the tablet area
xinput set-prop $STYLUS_CODE "Evdev Axis Calibration" 0, 2638, 1657, 0
xinput set-prop $STYLUS_CODE "Evdev Axes Swap" 0
xinput set-prop $SCREEN_CODE "Wacom Rotation" 3
xinput set-prop $SCREEN_CODE "Wacom Tablet Area" 0, 0, 26112, 16320
echo -n flipped > $DIRFILE
;;
* )
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment