Pages

Thursday, December 22, 2011

Lenovo X220 Tablet Screen Rotation Script

#!/bin/bash

currentConfig=( `xrandr -q | grep LVDS1` )
currentRotation=`echo ${currentConfig[3]}`

# Turns the TouchPoint off if in portrait mode
setTouchPoint() {
    if [ $1 == "on" ] ; then
        toggle="1"
    else
        toggle="0"
    fi;
   
    xinput set-prop "TPPS/2 IBM TrackPoint" "Device Enabled" $toggle;
}

# Main
if [ $currentRotation == "left" ] ; then
    desiredRotation="normal"
    desiredWacom="0"
    setTouchPoint on
elif [ $currentRotation == "right" ] ; then
    desiredRotation="inverted"
    desiredWacom="3"
    setTouchPoint off
elif [ $currentRotation == "inverted" ] ; then
    desiredRotation="left"
    desiredWacom="2"
    setTouchPoint off
else
    desiredRotation="right"
    desiredWacom="1"
    setTouchPoint off
fi

xrandr --output LVDS1 --rotate $desiredRotation
xinput set-prop "Wacom ISDv4 E6 Pen stylus" "Wacom Rotation" $desiredWacom
xinput set-prop "Wacom ISDv4 E6 Finger touch" "Wacom Rotation" $desiredWacom

No comments:

Post a Comment

Followers