Saturday, May 22, 2010

Configure Ubuntu 10.04 for Thinkpad X41 Tablet

Unlike previous versions of Ubuntu, Ubuntu 10.04 has xserver-xorg-input-wacom to support stylus out of box.


However, the stylus cannot rotate when we set screen rotation from system->preferences->monitor.  This causes much trouble for tablet PC users.  The problem can be solved by writing a small script to rotate both the screen and the stylus.


The biggest trouble is to find the correct name of the Wacom devices including  stylus, eraser, screen. To find the names one needs the following two commands which come with the package wacom-tools:


xsetwacom and xinput
However, the wacom-tools package available for previous ubuntu versions becomes conflicting with the built-in package xserver-xorg-input-wacom in 10.04 LTS. If we installed xserver-xorg-input-wacom first and then install wacom-tools. Then the stylus becomes un-recognizable. The following steps are what I made it:


1. Uninstall xserver-xorg-input-wacom   from synaptic package manger;


2. Install wacom-tools; Download linuxwacom-0.8.6-2.tar.bz2 and unzip it;
go to the prebuilt directory and


./install
3. check the output of


    xsetwacom list  and xinput -list
4. Install  xserver-xorg-input-wacom   from synaptic package manger;


5.  sudo gedit rotatetablet


#!/bin/sh


# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation.


rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o  '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"


# Using current screen orientation proceed to rotate screen and input tools.


case "$rotation" in
    normal)
#    -rotate to the right
    xrandr -o right
    xsetwacom set "Serial Wacom Tablet STYLUS"  Rotate  CW
    xsetwacom set "Serial Wacom Tablet" Rotate CW
    xsetwacom set "Serial Wacom Tablet eraser ERASER" Rotate CW 
    ;;
    right)
#    -rotate to normal
    xrandr -o normal
    xsetwacom set "Serial Wacom Tablet STYLUS" Rotate NONE
    xsetwacom set "Serial Wacom Tablet" Rotate NONE
    xsetwacom set "Serial Wacom Tablet eraser ERASER" Rotate NONE
    ;;
esac
7. Save the script rotatetablet in step 6 to /usr/bin.


chmod +x /usr/bin/rotatetablet




NOTE: the names in quotations "Serial Wacom Tablet STYLUS" are obtained from step 3.


8. Make a launcher at desktop for the executable rotatetablet and use it when rotation of the tablet is needed.


6. Reboot computer. It works.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home