Installing Ubuntu 8.10 (Intrepid Ibex) on a ThinkPad X61 Tablet

From ThinkWiki
Revision as of 18:50, 2 March 2009 by Jd (Talk | contribs) (Tilt detection)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is not complete, but it documents some differences from the Hardy page.

Installing Intrepid should work the same as on most other computers. If you don't have Ultrabase with a CD drive or another external CD drive, you can install from a USB drive.

Do not forget to install the mandatory wacom drivers before editing your xorg.conf! See the Wacom documentation of the official Ubuntu help. Basically, you need to install wacom-tools and xserver-xorg-input-wacom. You may get it using apt-get/Synaptic or from source.

Tablet specific features

Stylus

Enable it as described in Wacom_Serial_Tablet_PC_Stylus: Add to /etc/X11/xorg.conf:

Section "InputDevice"
  Driver        "wacom"
  Identifier    "stylus"
  Option        "Device"        "/dev/input/wacom"
  Option        "Type"          "stylus"
  Option        "ForceDevice"   "ISDV4"           # Tablet PC ONLY
EndSection

Section "InputDevice"
  Driver        "wacom"
  Identifier    "eraser"
  Option        "Device"        "/dev/input/wacom"
  Option        "Type"          "eraser"
  Option        "ForceDevice"   "ISDV4"           # Tablet PC ONLY
  Option        "Button1"       "3"               # This works better with Xournal
EndSection

Section "InputDevice"
  Driver        "wacom"
  Identifier    "cursor"
  Option        "Device"        "/dev/input/wacom"
  Option        "Type"          "cursor"
  Option        "ForceDevice"   "ISDV4"           # Tablet PC ONLY
EndSection

The main difference from Hardy, is that the option "Device" no longer takes the value "/dev/ttyS0", but "/dev/input/wacom" (due to a newer version of the driver). If your tablet supports MultiTouch, you can also add the section (untested - please remove this paranthesis if you have tested this successfully)

The Option Button1 3 incant in the eraser section is what I needed to add in order to make the tablet's eraser work with Xournal. I have not tested with other note-taking software.

Section "InputDevice"
  Driver        "wacom"
  Identifier    "touch"
  Option        "Device"        "/dev/input/wacom"
  Option        "Type"          "touch"
  Option        "ForceDevice"   "ISDV4"
EndSection

In addition you will need a ServerLayout section. If you already have one, add the lines:

   InputDevice    "stylus" "SendCoreEvents"
   InputDevice    "eraser" "SendCoreEvents"
   InputDevice    "cursor" "SendCoreEvents"

to it. If there is no such section (which is the default), it has to be added. It can then look like this:

Section "ServerLayout"
  Identifier    "Default Layout"
  Screen        "Default Screen"
  InputDevice   "stylus"  "SendCoreEvents"
  InputDevice   "eraser"  "SendCoreEvents"
  InputDevice   "cursor"  "SendCoreEvents" 
# InputDevice   "touch"   "SendCoreEvents" # Only a few TabletPCs support this type
EndSection

Uncomment the last line if you have a MultiTouch capable tablet. The Identifier can be whatever you want, and the Screen is whatever the Identifier of your screen section is. "Default Screen" is the default. Make sure that you have a newline after the last EndSection in your file.

Rotate screen when turning into slate mode

When you turn the screen to put the computer into slate mode (a.k.a. tablet mode) you typically want the picture on screen to rotate into portrait mode. The X61 generates an ACPI event when it is turned into slate mode and another event when it is turned back. We can then let acpid rotate the screen at this event. At the moment, Ubuntu does not automatically rotate the stylus when the screen is rotated. This means that if you touch the screen in one corner, the cursor will show up in another. We also want to remap the arrow keys so that what used to be left now becomes down, etc. so that the "wheel" work as expected.

First, we add two files for changing the arrow keys to /etc/acpi

Xmodmap.normalrotatedarrows:

keycode 111 = Up NoSymbol Up NoSymbol Up
keycode 113 = Left NoSymbol Left NoSymbol Left
keycode 114 = Right NoSymbol Right NoSymbol Right
keycode 116 = Down NoSymbol Down NoSymbol Down

Xmodmap.rightrotatedarrows:

keycode 114 = Up NoSymbol Up NoSymbol Up
keycode 111 = Left NoSymbol Left NoSymbol Left
keycode 116 = Right NoSymbol Right NoSymbol Right
keycode 113 = Down NoSymbol Down NoSymbol Down

The first of these is the default configuration and four of the lines you should get when you run xmodmap -pke. The second one rotates this the way we want for slate mode.

Next, we place two scripts in /etc/acpi

rotatescreenandstylus-laptop.sh

 
#!/bin/sh
#
# This script rotates the display in TabletPCs when screen is changed from
# slate to laptop mode

test -f /usr/share/acpi-support/key-constants || exit 0

. /usr/share/acpi-support/power-funcs

for x in /tmp/.X11-unix/*; do
	displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
	getXconsole;
	if [ x"$XAUTHORITY" != x"" ]; then
	    export DISPLAY=":$displaynum"
	    # Rotate the screen
	    /usr/bin/xrandr --orientation normal
	    # Rotate the stylus
	    /usr/bin/xsetwacom set stylus rotate none
	    /usr/bin/xsetwacom set eraser rotate none
	    /usr/bin/xsetwacom set cursor rotate none
	    # Rotate the arrow keys
	    xmodmap /etc/acpi/Xmodmap.normalrotatedarrows
	fi
done


rotatescreenandstylus-slate.sh

#!/bin/sh
#
# This script rotates the display in TabletPCs when screen is changed from
# laptop to slate mode

test -f /usr/share/acpi-support/key-constants || exit 0

. /usr/share/acpi-support/power-funcs

for x in /tmp/.X11-unix/*; do
	displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
	getXconsole;
	if [ x"$XAUTHORITY" != x"" ]; then
	    export DISPLAY=":$displaynum"           
	    # Rotate the screen
	    /usr/bin/xrandr --orientation right
	    # Rotate the stylus
	    /usr/bin/xsetwacom set stylus rotate cw
	    /usr/bin/xsetwacom set eraser rotate cw
	    /usr/bin/xsetwacom set cursor rotate cw
	    # Rotate the arrow keys
	    xmodmap /etc/acpi/Xmodmap.rightrotatedarrows
	fi
done

These two scripts are basically copied from /etc/acpi/rotatescreen.sh, but instead of just rotating the screen it also rotates the stylus and the arrow keys.


Finally, we need to make the scripts run when the ACPI events are generated. This is accomplished by adding files to /etc/acpi/events.

thinkpad-rotate-laptop:

 
# /etc/acpi/events/thinkpad-rotate-slate
# This is called when the user rotates the screen to/from tablet mode

event=ibm/hotkey HKEY 00000080 0000500a
action=/etc/acpi/rotatescreenandstylus-laptop.sh

thinkpad-rotate-slate:

# /etc/acpi/events/thinkpad-rotate-slate
# This is called when the user rotates the screen to/from tablet mode

event=ibm/hotkey HKEY 00000080 00005009
action=/etc/acpi/rotatescreenandstylus-slate.sh

This should be all. Next time you restart the computer or acpid, the screen/arrow key/stylus rotation should work when the computer is put into slate mode and back again.

Tilt detection

Unlike Hardy, Intrepid does not have the hdaps_ec module, but there is a workaround. This has been reported as bug 297213 in Launchpad. Basically, one need to :

compile tp_smapi with the following commands:
make HDAPS=1 KSRC=/usr/src/linux-headers-`uname -r`
sudo make install HDAPS=1 KSRC=/usr/src/linux-headers-`uname -r`
remove the following old-fashioned conf files:
rm /lib/modules/$KVER/kernel/ubuntu/misc/thinkpad_ec.ko
rm /lib/modules/$KVER/kernel/ubuntu/misc/tp_smapi.ko
rm /lib/modules/$KVER/kernel/drivers/hwmon/hdaps.ko
Replace them with those compiled at the previous step (sudo mv…)
Add the following lines to /etc/modprobe.d/local:
# enable thinkpad_ec
options thinkpad_ec force_io=1

# option to correctly set tilting through hdaps sensor
# it depends on your laptop conf, just try different numbers in the range [0-6]
# options hdaps invert=1
Start required modules:
sudo modprobe tp_smapi
sudo modprobe hdaps

One can then test the tilt feature with a program such as hdaps-gl or the game neverball.

Further reading: this blog post appears to have information on how to compile the kernel module. Be sure to `sudo modprobe hdaps` to load the kernel module, and add it to /etc/modules.conf (or equivalent) to load it at boot time.

(TODO: Figure out how to enable hard drive prodection with accelerometers)

External links

Customized Ubuntu Hardy Setup Guide on X61t Hardware.