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

Middle Click Scrolling with Lenovo TrackPoint

I just found this handy script when I got my new Lenovo X220 Tablet with a TrackPoint.  I couldn't get the middle click to work correctly with it; it was configured to be a middle click button (which makes perfect sense) but I wanted it to have scrolling capabilities.
You just add this to /etc/gdm/PostLogin/Default and give it executable rights.

#!/bin/sh

xinput list | sed -ne 's/^[^ ][^V].*id=\([0-9]*\).*/\1/p' | while read id
do
        case `xinput list-props $id` in
        *"Middle Button Emulation"*)
                xinput set-int-prop $id "Evdev Wheel Emulation" 8 1
                xinput set-int-prop $id "Evdev Wheel Emulation Button" 8 2
                xinput set-int-prop $id "Evdev Wheel Emulation Timeout" 8 200
                xinput set-int-prop $id "Evdev Wheel Emulation Axes" 8 6 7 4 5
                xinput set-int-prop $id "Evdev Middle Button Emulation" 8 0
                ;;
        esac
done


# disable middle button
xmodmap -e "pointer = 1 9 3 4 5 6 7 8 2"

Followers