Blzut3's Weblog

Weblog ECWolf ECWolf Wiki

Setting up Kubuntu on Lenovo X61 Tablet

Anyone with a convertible tablet PC would know that while Ubuntu more or less works out of the box, a few key functions such as the screen rotation button do not work. Here I'll describe how I implemented the screen rotation on Kubuntu 11.04, although most of it applies to Ubuntu in general.

Update (August 26th 1012): I just started using 12.04 on my tablet and I've made one minor change to this guide.

Screen Rotation Script

Create the file /usr/bin/rotate and fill it with the following script:

#!/bin/bash

# Get some information
RotationsWC=(none ccw half cw)
RotationsSC=(normal left inverted right)
Devices=`xsetwacom --list devices | grep -o -e '[0-9]*'`

# Determine our rotation
if [ $# -eq 1 ]
then
	Rotate=$(($1%4))
else
	if [ -e '/tmp/rotation' ]
	then
		Rotate=`cat /tmp/rotation`
	else
		Rotate=0
	fi
	Rotate=$((($Rotate+1)%4))
	echo $Rotate > /tmp/rotation
fi

# Perform actions
xrandr --output `xrandr | grep -o -e 'LVDS[0-9]'` --rotate ${RotationsSC[$Rotate]}
for i in $Devices
do
	echo $i
	xsetwacom set $i Rotate ${RotationsWC[$Rotate]}
done

Be sure to `chmod +x /usr/bin/rotate` after to make the script executable. The script itself will store the current rotation into memory (/tmp/rotation). The tablet's devices are queried through xsetwacom. After finding the next rotation, xrandr is used to set the screen's orientation and xsetwacom is used to rotate the pen interface.

If you are using a version prior to Ubuntu 12.04, swap the position of ccw and cw in the RotationsWC array.

Binding the Script to the Hardware Button

By default the rotation button isn't reachable through KDE. We can reassign the key code used by the button through setkeycodes. The scan codes can be found on the ThinkWiki article on the buttons. Open /etc/rc.local and add the following before the "exit 0" line.

setkeycodes 6c 212

The key code 212 binds to "WebCam" according to KDE. For me this works fine since the X61 doesn't have a webcam button. If someone can link me to a key code list I may be able to find a more suitable button.

Regardless, adding the line to rc.local will rebind the button at startup so either execute that command (as root) or reboot to enable the button.

Finally we need to make the button a shortcut to our script. For KDE, in System Settings, go to Shortcuts and Gestures->Custom Shortcuts->Edit->New->Global Shortcut->Command/URL. On the Trigger tab set the shortcut to the rotation button. Then on the Action tab set the command to rotate.

Trackpoint Sensitivity

Asssuming a ThinkPad tablet, Probably the first thing you will have noticed is the trackpoint feels a little off under Linux. The solution is quite simple as explained by this ThinkWiki article. Personally I'm not able to tell a difference when changing the trackpoint's speed, but a sensitivity 255 works for me. So run `sudo nano /etc/udev/rules.d/trackpoint.rules` and enter the following:

SUBSYSTEM=="input",ATTR{name}=="*TrackPoint*",RUN+="/etc/udev/trackpoint"

Then create the file /etc/udev/trackpoint with the following contents:

#!/bin/sh
echo -n 255 > /sys/devices/platform/i8042/serio1/sensitivity

Be sure to run `sudo chmod +x /etc/udev/trackpoint` as well to make it executable. One thing to note is the WAIT_FOR method does not work for me on my X61 Tablet. (I was able to get it to work on a R60 though.)

 

© 2004-2016 Braden "Blzut3" Obrzut