Posts Tagged ‘screen rotation’

The Tablet and the Jackalope

Thursday, June 18th, 2009

Yesterday, I did something that I’ve never done before – a mid-semester major distribution upgrade.  I have a Thinkpad X61 Tablet which I use for teaching, and that tablet runs Ubuntu Linux.  I’ve also set Patty up with a Thinkpad X41 tablet to replace her ancient Thinkpad X31

So how did it go?

Thinkpad X41 Tablet

Ubuntu has been broken by default on tablet PCs for some time.  By “broken”, I mean that after an installation, the tablet stylus doesn’t work.  If you know what you’re doing, it’s not too difficult to make it work, but it’s still a headache that shouldn’t exist.

With the latest Ubuntu (Jaunty Jackalope), the tablet pen functions without any additional configuration.  In fact, essentially all of the X41’s most important hardware is configured on installation.  But there are a few exceptions, and here they are!

Fingerprint reader

The fingerprint reader is not set up automatically.  Since I don’t use the reader, I didn’t feel that manually setting up the fingerprint reader was a deal-breaker.

Tablet keys

The tablet keys (underneath the display) are not configured by default.  This one is a bigger deal, since you’ll need those keys to use the tablet as, well, a tablet.  After is bit of googling, here’s the fix to get the X41 tablet keys going.

Essentially, make a script that contains this:


#!/bin/sh -e
setkeycodes 6e 109
setkeycodes 6d 104
setkeycodes 69 28
setkeycodes 6b 1
setkeycodes 68 130
setkeycodes 6c 131
setkeycodes 67 132

… and save it as (or add it to) /etc/rc.local

This script is executed every time you boot up.  It assigns the correct keycodes to the tablet keys.  (This is something you didn’t have to do in previous Ubuntu releases.)

Rotation

To use the tablet as intended, you probably want to rotate the display.  As with all previous incarnations of Ubuntu, this is not set up for you after the installation.  You’ll find various scripts on the internet for rotating the screen and stylus, but most of them won’t work on Ubuntu Jaunty Jackalope because of … the way the tablet pen is automatically configured.  So, the pen is now set up for you, but it’s set up in such a way as to make changing its behavior (which you’ll need to do to rotate the screen) more difficult.

Here’s a simple rotation script thta works with Ubuntu Jaunty Jackalope on the X41 tablet and X61 tablet, provided you have the 1024×768 screen.  If you have a larger screen, you’ll need to modify the script accordingly.  Save it as /usr/local/bin/rotation.sh


#!/bin/bash
orientation=`xrandr -q | grep -c 1024x768`
echo $orientation
if [ $orientation -eq 2 ]; then
/usr/bin/X11/xrandr --orientation right
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer" Rotate 1
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer eraser" Rotate 1
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer" xyDefault
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer eraser" xyDefault
else
/usr/bin/X11/xrandr --orientation normal
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer" Rotate 0
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer eraser" Rotate 0
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer" xyDefault
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer eraser" xyDefault
fi

Execute the script, and the screen and stylus will be rotated. Execute it again, and the screen and stylus will return to their normal orientation. This is good to assign to the “rotate” button underneath the screen, but you can execute the script from a terminal as well.

Thinkpad X61 Tablet

Setting up Ubuntu Jaunty Jackalope on the X61 tablet is fairly similar to setting it up on the X41 tablet.  As before, much of the important stuff is automatically set up by the installation.  However, the X61 tablet has a few more quirks than the X41 does.  Here they are!

Fingerprint reader

Same as the X41 tablet.

Tablet keys

By default, the directional keys, enter, and the escape button work as expected.  The other keys will require a similar script to the X41 9above).  I haven’t messed with figuring out the keycodes for the X61 tablet yet, though.

Rotation

Same as the X41 tablet.

Desktop effects

On the X41 tablet, these “just work”.  On the X61 tablet, they will “just work” when a certain set up updates is made official in Ubuntu Jaunty Jackalope.  But as of 6/17/09, you’ll need to enable the “proposed” repository (which contains the newest updates that haven’t gone through as much quality control as what you’d get through the normal update channel). 

Here’s how to enable the proposed repository.  You need the latest compiz and xserver-xorg-video-intel packages to get desktop effects working.

Or, you can wait until the compiz and xserver-xorg-video-intel updates become official.

Improving video performance

The X61 tablet (and the X41 tablet, too) have Intel video cards.  The Intel video driver for Linux is currently in the middle of a redesign.  That’s bad for laptop users, because it makes video performance in recent releases of Ubuntu quite horrible.  The X41 tablet is affected somewhat, but the X61 tablet suffers terribly from the reduced performance.

The real fix for the video problems won’t come until the next release of Ubuntu, but you’ll likely want to be able to use your computer properly before then.  Here’s what you need to do:  Follow this HOWTO from the Ubuntu forums.  I used the “optimal” procedure, and am getting better video performance without any crashes so far.

(This procedure will also work for the X41 tablet, but with a more modest performance gain.)

Changing the pen’s behavior

The X61’s stylus features an eraser tip, a side button, and a pen tip.  I wanted the side button to bring up context menus and the eraser to paste (when not being used by an application like xournal).  So, I made a little script to change the behavior of the buttons.


#!/bin/bash
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer" Button1 "button 1"
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer" Button2 "button 3"
xsetwacom set "Wacom Serial Tablet PC Pen Tablet/Digitizer eraser" Button1 "button 2"

I saved this as /usr/local/bin/stylusbuttons.sh, which i have set to run when I log in. Now the stylus buttons work the way I want.

I’ve managed to get though a day of teaching wit hthe new install without incedent.  So far, so good!  Anything to add?  Improvements to the stuff above?  Configuration questions?  I’m all ears!