www.volker-lanz.de
Linux SUSE Linux 9.2 on an IBM Thinkpad T41p >>

Getting the IBM Thinkpad's function keys to work on SUSE Linux 9.2

If you have read my essay on running SUSE Linux 9.2 on an IBM Thinkpad T41p, you know that the Thinkpad's special function keys (like Fn+F3 for "backlight off" or Fn+F12 for "suspend to disk") don't work by default after installing SUSE Linux 9.2.

They can be made to work, however, this requires quite some effort. Let me describe the process here for you.

Building your own kernel

SUSE 9.2 is becoming a dated distribution as of now (SUSE 9.3 is about to be released, but is rumoured to be less than spectacular) and quite a few Kernel updates have been released since it saw the light of day. Thus, the first thing we need to do is update the ageing 2.6.8 kernel to 2.6.11. Please note that you might probably get away with running the SUSE Linux kernel 2.6.8, but I have not tried this: Running a newer kernel than 2.6.8 had become a necessity for me before, because 2.6.9 and 2.6.10 both have important fixes in the USB department I needed to get my USB stick (an LG X-Tick) to work. To enable all of the Thinkpad's function keys, we need to use the ibm_acpi kernel module, and a quite recent version of this comes with 2.6.11. If you do not want to update your kernel, it might suffice to get the ibm_acpi sources and build the module only. This, however, is not covered here.

How to build your own kernel is described in various documents found on the web, so I won't cover the process in greater detail here. There are a few SUSE-Linux-specific things to note, however:
  • The vanilla kernels from kernel.org do not come with the Madwifi driver required for the Thinkpad's Atheros Wireless chip. So, before booting your new kernel, go to the Madwifi Project's page on SourceForge and get the sources via CVS or snapshot. You will have to build the madwifi kernel modules once you're running the new kernel.
  • If you're using subfs to automatically mount CDs or other media, you will need to get the submount sources from the Submount Project's page on SourceForge. Like with Madwifi, you will have to compile the subfs kernel module once you've got kernel 2.6.11 running. Note that there's no need to build and install the userspace tools.
  • If you are running VMWare on your Thinkpad, you will need to get the latest vmware-any-any-patches from http://ftp.cvut.cz/vmware/ to recompile the VMware modules.
If you do not feel like going through the hassle of configuring the kernel yourself, here's the config file I used for my Thinkpad T41p. It is based on the SUSE Linux 9.2 config file with a few things turned off (like amateur radio support). Most kernel features, however, are on and being built as modules.

Setting up the ibm_acpi kernel module

With the new kernel up and running, it's time to get the ibm_acpi kernel module to work. First of all, we need to make sure it is loaded when the Thinkpad boots up, so we add the following lines to /etc/init.d/boot.local:
modprobe ibm_acpi experimental=1
echo enable > /proc/acpi/ibm/hotkey
echo 0xffff > /proc/acpi/ibm/hotkey
The first line inserts the module and turns on its experimental features (don't worry, we won't do anything potentially harmful). The second line enables the hotkeys and the third line tells the module to pass all hotkey events to acpid.

SUSE Linux 9.2 uses acpid only to pass on the ACPI events to powersaved, so there's no use in configuring acpid to do anything with the special IBM hotkey events we now get. However, you should see these events in acpid's logfile, /var/log/acpid.

Configuring powersaved

We are now going to deal with all hotkey events ourselves, so first we need to make sure powersaved does ignore the events we want to process and passes them on to a script of our own.

Make sure you have these lines in /etc/sysconfig/powersave/events:
POWERSAVE_EVENT_BUTTON_POWER="ignore"
POWERSAVE_EVENT_BUTTON_SLEEP="ignore"
These settings make sure powersaved doesn't process the events generated when the "sleep button" (powersaved thinks this is Fn+F3) is pressed or when the power button is pressed.

To make powersaved pass on the hotkey events to us, we need to add another line to /etc/sysconfig/powersave/events:
POWERSAVE_EVENT_OTHER="acpi_hotkeys_IBM_t41p"
This line has the effect of powersaved calling the script /usr/lib/powersave/scripts/acpi_hotkeys_IBM_t41p each time an event is to be processed that it doesn't itself know how to deal with. Of course, this script does not yet exist. We will have to provide it ourselves.

The hotkey script

For the impatient: Get the script, put it in /usr/lib/powersave/scripts/, and you're done. Make sure you have the radeontoolbinary installed in /usr/local/sbin, or Fn+F3 will not work.

The script's inner workings are pretty straightforward: Depending on what arguments it is called with by powersaved, it triggers certain actions: For Fn+F4, for example, it calls powersave -u to put the machine to suspend to ram. It also makes the sleep-LED blink before doing so, to indicate that the Thinkpad did indeed receive the hotkey event.

The script processes Fn+F3, Fn+F4, Fn+F5, Fn+F7 and Fn+F12. Unfortunately, Fn+F7 doesn't really work. This is apparently caused by the X.org-radeon-driver. The script also handles the lid close event, because for some reason I did not quite understand powersaved stopped processing this event for me after setting up the script. I find this surprising because I still have
POWERSAVE_EVENT_BUTTON_LID_CLOSED="suspend_to_ram"
in /etc/sysconfig/powersave/events. Anyway, adding the LID_CLOSE event to the script works without a problem.

Fn+F5 turns off bluetooth and shuts down ath0. Pressing it again turns on bluetooth and gets ath0 up again. If you never ever need bluetooth, you might want to comment out the lines
                        echo enable > /proc/acpi/ibm/bluetooth
$BLUETOOTH start
from the script, because having bluetooth running all the time consumes power that is of course wasted if you don't use bluetooth at all.

If you have radeontool installed, but the binary is not located in /usr/local/sbin, you will need to adjust the RADEONTOOL variable at the top of the script to point to where you have it on your Thinkpad.

Summary

Getting the IBM Thinkpad's function keys to work under SUSE Linux 9.2 requires a little tweaking and fiddling, but is not an unsurmountable task. The hardest part, for me at least, was to find out how to pass on unprocessed events from powersaved to a user-supplied bash script. The Thinkpad now properly goes to sleep (suspend-to-ram) when Fn+F3 is pressed and hibernates (suspend-to-disk) with Fn+F12. Also, Fn+F5 toggles WLAN and Bluetooth on and off.

Not all function keys are being processed by powersaved and the bash script, however. The brightness keys, the zoom function (on space bar), the ThinkLight key and the Access IBM key are still being dealt with by tbp.

Linux SUSE Linux 9.2 on an IBM Thinkpad T41p >>