The ThinkVantage Button and Ubuntu Hardy Heron
While working on my ThinkPad X61, I realized that the ThinkVantage button was not working on Ubuntu Hardy Heron. Even though there isn’t any special application for Linux, I still though it would be a good idea to use the button to launch GNOME Terminal (which I use quite often).
After doing some research, it turns out that the ThinkVantage button reports events through the ACPI system. There is a script called thinkpad-thinkpad.sh in the /etc/acpi directory that gets called everytime you press it, which in turn fires an X11 event using the acpi_fakekey command. This worked out of the box for me, and you can check if it works for you by looking at the ACPId log with the tail -f /var/log/acpid command. If you press the ThinkVantage button, you should see the following in the log:
[Sat Jun 14 18:18:45 2008] received event “ibm/hotkey HKEY 00000080 00001018”
[Sat Jun 14 18:18:45 2008] notifying client 6445[0:0]
[Sat Jun 14 18:18:45 2008] notifying client 6304[111:123]
[Sat Jun 14 18:18:45 2008] executing action “/etc/acpi/thinkpad-thinkpad.sh”
[Sat Jun 14 18:18:45 2008] BEGIN HANDLER MESSAGES
[Sat Jun 14 18:18:45 2008] END HANDLER MESSAGES
[Sat Jun 14 18:18:45 2008] action exited with status 0
[Sat Jun 14 18:18:45 2008] completed event “ibm/hotkey HKEY 00000080 00001018”
But the problem is that an invalid scan code is being reported and so gets dropped by the kernel input hander, as reported by Bug #217504. There is already a working patch in the works and will be included in Ubuntu at some time in the future. But in the meantime, there is a simple fix that you can apply to get it working. Just add the following two lines to the /etc/rc.local file. The first line enables the ThinkVantage button and the second line enables Fn+SPACE, which is affected by the same problem.
setkeycodes e017 148
setkeycodes 0082 192
The next step is to load these changed by running the command:
sudo /etc/init.d/rc.local restart
You can test that everything works by running the xev command, focusing the new window and pressing the ThinkVantage button. If everything worked right, you should see the following lines appear in the terminal:
KeyPress event, serial 30, synthetic NO, window 0x4000001,
root 0x5a, subw 0x0, time 11998453, (31,116), root:(996,165),
state 0x0, keycode 159 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
If you see something similiar to that line above, then everything worked right! You can now use the GNOME Keyboard Shortcuts, or some other shortcut system, to assign this button to an action.