Tuesday, January 22, 2008

Let HAL work with thinkpad_acpi

With the new thinkpad_acpi module succeeding ibm_acpi, there is one great thing going on. Hot key presses are now sent to the input layer, which means you can handle them as real key press/release events and throw those ACPI handlers into garbage bin. The current version of HAL, however, is not working well with the event device created by thinkpad_acpi. Newer kernels come with SW_RADIO switch event which is the only SW bit used by thinkpad_acpi, but HAL fails to follow up the steps. Thus the pre-probing during HAL's process of adding a new input device will fail with no supported SW bits found. Simply put, HAL will not listen on that event device, which most probably renders it useless unless you write your own event handlers for it.

As simple as it is, I spent quite some time digging it up from the source code. Then when I posted it to the HAL mailing list, Ben Liblit kindly pointed me to this bug entry, where he provided a nice patch for HAL. Trust me, I searched around it really hard before getting into the source code, and Google failed to get me this link. Shame for Google. ;)

So if your HAL is 0.5.10, just apply the patch. Make sure your linux/input.h is new enough to contain SW_RADIO. With earlier versions, try searching for every appearance of SW_HEADPHONE_INSERT and make modifications accordingly.

With HAL 0.5.10, you can get quirks from this page to get correct keymaps (and other stuff) for your model. With older versions, like me, you can use my little program to map your keys your way.

thinkpad-acpi-keys.tar.gz

Compile setevkeycodes.c and put it in /usr/local/sbin. Install thinkpad-acpi as a service and copy thinkpad-acpi-keymap to /etc/default. If you prefer to use different paths, modify thinkpad-acpi script accordingly. FYI, the keymaps in thinkpad-acpi-keymap are my current settings, on a T60.

Tuesday, January 15, 2008

A subtle change in event interfaces with the new kernel

I'm finally fed up with the stock kernel 2.6.20 of Ubuntu feisty, because I want to try out the iwlwifi driver for my intel 3945 wireless card. The new kernel is 2.6.23.13, and I noticed a subtle change in event interfaces, which breaks acpi_fakekey for many special keycodes. It's when you write an "unsupported" keycode to an event device, the old kernel will take it and propagate it to all processes listening on that device, but the new kernel just ignores it, pretending nothing has happened. Here I use the term "unsupported" to refer to being unmasked by the device keybits. acpi_fakekey is doing a pretty simple job here: find the first keyboard device and write the key press/release event to it, without regard to the true capabilities of that device. Now you see how this change breaks it.

Tuesday, January 8, 2008

deb packages of clewn 1.13

I recently discovered clewn, a nice piece of software that glues gdb and gvim together to form a "integrated" debugging environment. It lets you set breakpoints "visually" and step through your program in quite a interactive manner. Its "point and pop up" style of displaying variable values is also very fancy and convenient. As the communications are done through NetBeans, it's also possible to debug remote programs in your local gvim window.

Quote the descriptions from their website:

Clewn implements full gdb support in the vim editor: breakpoints, watch variables, gdb command completion, assembly windows, etc.

This may be done in two different ways, using clewn or vimGdb. Clewn is a program controlling vim through the netBeans socket interface, it runs concurrently with vim and talks to vim. Clewn can only be used with gvim, the graphical implementation of vim, as vim on a terminal does not support netBeans. VimGdb is a vim patch implemented as a vim optional feature.

Both alternatives use the same base source code to interface with gdb. Clewn, as a standalone process, needs its own terminal. This is not the case with vimGdb, but a drawback is that a different patch must be applied to each new Vim version.

They both share the same features set, except clewn supports some features that vimGdb does not have:

  • display of gdb expression values in a balloon
  • gdb `run' commands do input and output on the clewn terminal, while vimgdb users must use the gdb 'tty' or 'attach' commands to control the debuged program input/output
I made the deb packages on an Ubuntu Feisty, i386. Not tested on other distros but should work as long as dependencies are satisfied.

clewn_1.13-1~jason1_i386.deb
clewn-vim_1.13-1~jason1_i386.deb

Grab & install them, then vim, :h clewn, and there you go!

UPDATE: April 3, 2008
Repackaged in accordance with the Debian Packaging Policy for Vim.
clewn_1.13-1~jason2_i386.deb
vim-clewn_1.13-1~jason2_all.deb