Installing Linux, Ubuntu 8.04 Hardy, on a IBM Thinkpad X41 Tablet

UPDATE Aug 08 AUTOMATIC SCREEN ORIENTATION (based on HDAPS Orientation Sensor)
(See Below).

This document describes the process of configuring Linux, Ubuntu 8.04 Hardy (release 2008) on a IBM ThinkPad X41 Tablet, with my scripts and patches to download.

ENABLE STYLUS

/etc/X11/xorg.conf

#Uncomment if you have a wacom tablet
        InputDevice     "stylus"        "SendCoreEvents"
        InputDevice     "cursor"        "SendCoreEvents"
        InputDevice     "eraser"        "SendCoreEvents"
        #InputDevice    "Synaptics Touchpad"

apt-get install wacom-tools

To download xorg.conf, for reference.

FINGERPRINT READER AND HDAPS SENSOR

x41hdaps_t.jpg

/etc/modules

Add:

#Required for Fingerprint Reader
uinput  
#Thinkpad access to the embedded controller. Battery
tp_smapi  
#IBM Active Protection System and Orientation Sensor
hdaps_ec  

For Fingerprint sensor see How_to_enable_the_fingerprint_reader_with_ThinkFinger and my entry.

To try orientation sensor, apt-get install hdapsd hdaps-utils, then use hdaps-gl.
Add this to /etc/modprobe.d/options to correct orientation.

#Hdaps Orientation
options hdaps invert=3
options hdaps_ec invert=3

SCRIPT TO ROTATE SCREEN, ACPI SWIVEL EVENTS AND TABLET BUTTONS

x41rot_t.jpg

I have made this script in /usr/local/bin/rotatetablet (it’s is based on a script by Saikat Guha found here). It rotates screen, rotates stylus, changes tablet page down/up keys, and deactivate compiz if active (Because Compiz freezes with xrand )*. Arguments are [left|right|inverted|normal] or empty for next.

#!/bin/bash

#STATUS_FILE=~/.rotate-status
STATUS_FILE=/tmp/.rotate-status

################## Compiz Prevention
function compiz_on {
   USER=`ps -ef |grep metacity |grep -v grep|awk -F" " '{print $1}'`
   #if [ "$(pidof metacity)" ]
   if [ "$USER" ]
   then
      echo 'Activating Compiz...'
      #DISPLAY=":0.0" sudo -H -u $USER /usr/bin/compiz --replace &
      #DISPLAY=":0.0" sudo -H -u $USER /usr/bin/emerald --replace &
   fi
}

function compiz_off {
   USER=`ps -ef | grep compiz.real | grep -v grep | awk -F" " '{print $1}'`
   #if [ "$(pidof compiz.real)" ]
   if [ "$USER" ]
   then
      echo 'Compiz Active. Deactivating...'
      DISPLAY=":0.0" sudo -H -u $USER /usr/bin/metacity --replace &
   fi
}
##################################################

######################## Keycodes PgUp/PgDown
function keymap() {
   USER=`who |grep tty7 |awk -F" " '{print $1}'`
   if [ "$USER" ]
   then
      case "$1" in
      1)
         echo 'Modifying xmodmap ...'
         DISPLAY=":0.0" sudo -H -u $USER xmodmap -e 'keycode 105 = Prior'
         DISPLAY=":0.0" sudo -H -u $USER xmodmap -e 'keycode 99 = Next'
         ;;
      *)
         echo 'xmodmap normal ...'
         DISPLAY=":0.0" sudo -H -u $USER xmodmap -e 'keycode 105 = Next'
         DISPLAY=":0.0" sudo -H -u $USER xmodmap -e 'keycode 99 = Prior'
         ;;
      esac
   fi
}
###############################
function rotate() {

    case "$1" in
        3|right) N=3; T=cw ; compiz_off ; keymap 0 ;;
        1|left) N=1; T=ccw ; compiz_off ; keymap 1 ;;
        2|inverted) N=2; T=half ; compiz_off; keymap 0 ;;
        0|normal) N=0; T=none ; compiz_on ; keymap 0 ;;
        *)
           echo -e "Usage:n  $(basename $0) [left|right|inverted|normal]";
 echo -e "if no option is given, rotates the screen 90 degrees to the right.n";

           exit 1
           ;;
    esac

    #xrandr -o $N & 

    #More secure
    if [ "`/usr/bin/xrandr -o $N -v | grep -i 'randr' | wc -l`" -ne "1" ]
    then
        echo '!! Something went wrong...'
        export DISPLAY=":0.0"
        export XAUTHORITY=/var/lib/gdm/:0.Xauth
        #/usr/bin/xset -display $DISPLAY dpms
        echo 'Trying to unrotate again...'
        /usr/bin/xrandr -o $N &
    fi

    xsetwacom set stylus Rotate $T & 
    echo $N > $STATUS_FILE
}

if [ "$#" == "0" ]; then
    rotate $(((3+0$(cat $STATUS_FILE 2>/dev/null))%4))
else
    rotate $1
fi

To download rotatetablet script. (Make it executable with chmod +x )

Then create these 4 files to call it in response to acpi events:

/etc/acpi/events/x41t-swivel-down

# /etc/acpi/events/x41t-swivel-down
# called when tablet head swivels down
event=ibm/hotkey HKEY 00000080 00005009
action=/etc/acpi/x41tsdown.sh

/etc/acpi/events/x41t-swivel-up

# /etc/acpi/events/x41t-swivel-up
# called when tablet head swivels up
event=ibm/hotkey HKEY 00000080 0000500a
action=/etc/acpi/x41tsup.sh

/etc/acpi/x41tsdown.sh (with chmod +x)

#!/bin/sh
#/etc/acpi/x41tsdown.sh

echo 'Rotating Tablet...'
/usr/local/bin/rotatetablet right

/etc/acpi/x41tsup.sh (with chmod +x)

#!/bin/sh
#/etc/acpi/x41tsup.sh

echo 'Unrotating Tablet...'
/usr/local/bin/rotatetablet normal

I use keylaunch (apt-get install keylaunch) to enable tablet buttons. It can be automatically started in Gnome Session programs. First button calls previous rotatetablet script and second one calls cellwriter program for tablets (apt-get install cellwriter) .

In $HOME/.keylaunchrc

key=...XF86RotateWindows:/usr/local/bin/rotatetablet
key=...F21:cellwriter

In $HOME/.Xmodmap

! back and forward browser keys
keycode 234 = F19
keycode 233 = F20

!Thinkpad Tablet Rotate
keycode 203 = XF86RotateWindows
!Thinkpad Tablet Menu
keycode 193 = F21
!Thinkpad Access IBM
keycode 159 = F22
!Thinkpad Tablet Reset
keycode 146 = F23

————-
[*] It’s possible to deactivate Compiz windows manager by default, edit /usr/share/gnome/default.session, and replace line:

0,RestartCommand=gnome-wm --sm-client-id default0

by

0,RestartCommand=gnome-wm --default-wm /usr/bin/metacity --sm-client-id default0

—————

BOOT IN CONSOLE MODE, AND WITH COLORS. [OPTIONAL]

x41boot_t.jpg

For boot in console mode:

/boot/grub/menu.lst

Add to kernel options vga=0×317 and remove splash.

kernel   /boot/vmlinuz-2.6.24-19-generic root=... ro quiet vga=0x317 nohz=off 

Then grub-install /dev/sda

In /etc/modprobe.d/blacklist-framebuffer, comment #blacklist vesafb to enable vesa framebuffer.
In /etc/initramfs-tools/modules, add

#Framebuffer modules
fbcon
vesafb

Then update-initramfs.

To activate colors I have done a patch for file /etc/lsb-base-logging.sh.
Localize the first line and comment inside lines. Leave it like this:

 if [ "$COL" ] & & [ -x "$TPUT" ]; then
        #printf "r"
        #$TPUT hpa $COL
        #if [ "$1" -eq 0 ]; then
        #    echo "[ OK ]"
        #else
        #    printf '['
        #    $TPUT setaf 1 # red
        #    printf fail
        #    $TPUT op # normal
        #    echo ']'
        #fi

        #PATCH
        COLS=`$TPUT cols`
        if [ -n "$COLS" ]; then
            COL=`$EXPR $COLS - 7`
        else
            COL=73
        fi

        UP=`$TPUT cuu1`
        END=`$TPUT hpa $COL`
        START=`$TPUT hpa 0`
        RED=`$TPUT setaf 1`
        NORMAL=`$TPUT op`
        GREEN=`$TPUT setaf 2`
        if [ $1 -eq 0 ]; then
            echo "$END[${GREEN} OK ${NORMAL}]"
        else
            echo "$END[${RED}fail${NORMAL}]"
        fi
        #END PATCH

 else

To download patched lsb-base-logging.sh

KEYBOARD IN GDM AND SCREEN LOCK

x41keyb_t.jpg

apt-get install cellwriter

GDM

In /etc/gdm/Init/Default, before exit 0, add:

/usr/bin/cellwriter --keyboard-only --read-only --window-y=600 --window-x=200 &

In /etc/gdm/PostLogin/Default, add:

killall -u root cellwriter &

In /etc/gdm/PostSession/Default, before exit 0, add:

sudo killall -u $USER cellwriter

SCREEN LOCK

Edit Gnome Registry with gconf-editor. In apps/gnome-screensaver

embedded_keyboard_command cellwriter --keyboard-only --xid
embedded_keyboard_enabled [TRUE]

SCREENSHOT, LINUX ON THINKPAD X41 TABLET

ubudesk_t.jpg

/*
UPDATE Aug 08
*/

AUTOMATIC SCREEN ORIENTATION (based on HDAPS Orientation Sensor)

Scripts (and instructions) by Dave Clawson

apt-get install libproc-process-perl (To install Perl module Proc::ProcessTree)

Download…
orientation tool: orient
orientation daemon: orientd
rotatetablet script: rotatetablet

The instructions to do this are as such:

1. Place the attached scripts (’orient’ and ‘orientd’) in /usr/local/bin and make them executable
2. Substitute /etc/acpi/x41tsup.sh and /etc/acpi/x41sdown.sh with these new versions and make sure that they’re executable.

/etc/acpi/x41tsdown.sh (with chmod +x)

#!/bin/sh
#/etc/acpi/x41tsdown.sh

#echo 'Rotating Tablet...'
#/usr/local/bin/rotatetablet right

echo 'Starting orientd...'
/usr/local/bin/orientd start

/etc/acpi/x41tsup.sh (with chmod +x)

#!/bin/sh
#/etc/acpi/x41tsup.sh

echo 'Stopping orientd...'
/usr/local/bin/orientd stop 

echo 'Unrotating Tablet...'
/usr/local/bin/rotatetablet normal

3. Put the following line in /etc/rc.local (before the “exit 0” line):

/usr/local/bin/orient reorient

…and that should do it.

NOTE: /usr/local/bin/rotatetablet needs the ‘compiz –replace’ line uncommented if you use compiz.

bz.otsoa.net

AdS

Admin area