Configuring Special Keys on a ThinkPad T60 (Arch Linux)

Posted by Ryan Coyner on November 4, 2008 under Arch Linux - 0 Comments

Life has kept me on my toes the last month but I finally managed to find some time to hack around on my laptop. I never bothered to configure the function key combinations on my ThinkPad T60 so I spent a couple of hours setting that up.

When I installed Arch Linux back in May, it automatically detected and loaded the sound and ACPI modules snd-hda-intel and thinkpad_acpi, respectively. Without any hacking, the following buttons and function key combinations worked thanks to the automated setup:

That left only a few special keys and function key combinations that I had to manually configure for my own needs. More specifically, I wanted to:

  1. Get the forward and back buttons to flip through the workspaces in Fluxbox.
  2. Get the function key combination for sleep and hibernation to work.
  3. Get the function key combination for toggling bluetooth to work since disabling bluetooth saves some battery power.

Forward and Back Buttons

Getting the Forward and Back buttons to work was simple. I first looked up the keycodes for both keys by running xev and pressing the buttons. For instance, the Back key returned this:

KeyRelease event, serial 34, synthetic NO, window 0x1a00001,
    root 0x5b, subw 0x0, time 30475365, (377,169), root:(622,439),
    state 0x0, keycode 234 (keysym 0xffd0, F19), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

The keymap needs to be modified so that the keycode is mapped to a specific key. This can be done by creating a ~/.xmodmaprc file. In my case the keycodes need to be mapped to F19 and F20 which are the Forward and Back keys. My ~/.xmodmaprc file contains the following:

keycode 234 = F19
keycode 233 = F20

You need to tell Fluxbox to automatically load this file when it starts up. Add this in your ~/.fluxbox/startup file:

xmodmap ~/.xmodmaprc
exec /usr/bin/fluxbox

Add these declarations in ~/.fluxbox/keys:

None F19 :PrevWorkspace
None F20 :NextWorkspace

Restart Fluxbox and the keys should work!

Bluetooth, Sleep and Hibernation

Getting sleep and hibernation to work was not difficult but was a little bit more involved. First, install the following packages via pacman:

$ sudo pacman -S acpid hal pm-utils

acpid is a daemon that listens for ACPI events in the /proc/acpi/event file and handles the event. I manually configured the handler script to get the function key cominations to work.

pm-utils provides the programs for sleeping and hibernating but requires hal for it to work properly. I don't think pacman recognized the dependency so you will have to manually tell pacman to download it.

With acpid and hal installed, they should always be started when the system boots. Add them into the DAEMONS array in rc.conf:

 
DAEMONS=(syslog-ng !network netfs @crond @alsa @postgresql @acpid @hal)

For hibernation to work, the boot loader needs to know which partition to restore the current session from when waking up. Hibernation places the current session in the swap partition, so figure out the name of your swap partition and add the following in /boot/grub/menu.lst if you are using GRUB:

# (0) Arch Linux
title  Arch Linux
root   (hd0,1)
kernel /vmlinuz26 root=/dev/disk/by-uuid/d4a15d35-8c13-4971-939b-884e93d7fc01 resume=/dev/sda1 ro
initrd /kernel26.img

At this point your computer should be able to sleep and hibernate. You can test this by running pm-suspend and pm-hibernate respectively.

Now the ACPI handler script needs to be modified so that it recognizes the ACPI calls made by the function key combinations for sleeping and hibernating. Make the following additions in /etc/acpi/handler.sh:

    ibm/hotkey)
        case "$4" in
            00001004)
                logger "acpid: sleep button (Fn+F4) pressed; suspending"
                /usr/sbin/pm-suspend
            ;;
            00001005)
                logger "acpid: bluetooth button (Fn+F5) pressed; toggling bluetooth"
                if grep -q enabled /proc/acpi/ibm/bluetooth ; then
                    echo disable > /proc/acpi/ibm/bluetooth
                else
                    echo enable > /proc/acpi/ibm/bluetooth
                fi
            ;;
            0000100c)
                logger "acpid: hibernate button (Fn+F12) pressed; hibernating"
                /usr/sbin/pm-hibernate
            ;;
            *)
                logger "acpid: action undefined: $4"
                ;;
        esac
        ;;

The function key combinations should now work.

Other Keys

Some other function key combinations that are on the ThinkPad T60 that I haven't touched are:

I may configure these sometime in the future but I have no immediate need for them. Here are a list of events if you want to do it yourself.

0 Comments

Post a Comment

Notoriety

Delicious

Recent Entries

11/24/08 - Backup and Synchronization with Git

11/4/08 - Configuring Special Keys on a ThinkPad T60 (Arch Linux)

9/16/08 - Building Packages in Arch Linux

9/6/08 - Setting Up Wireless on a ThinkPad T60 (Arch Linux)

7/28/08 - Customized Logging in Apache 2.2

Recent Comments

1/2/09 - Backup and Synchronization with Git

12/29/08 - Building Packages in Arch Linux

12/26/08 - Building Packages in Arch Linux

11/26/08 - Backup and Synchronization with Git

11/25/08 - Backup and Synchronization with Git