How to get special keys to work

From ThinkWiki
Revision as of 03:23, 5 November 2004 by Wyrfel (Talk | contribs) (added lots of info)
Jump to: navigation, search

Overview

key standard function tool configurability remarks
Fn - xmodmap, tpb full on release without completed key combination
Fn-F3 blank screen ibm-acpi, thinkpad-acpi full
Fn-F4 suspend to ram ibm-acpi, thinkpad-acpi full
Fn-F5 switch bluetooth thinkpad-acpi ??? in models starting from 2002
Fn-F7 switch display thinkpad-acpi, tpb additional actions
Fn-F8 toggle display expansion thinkpad-acpi, tpb additional actions
Fn-F9 eject from dock thinkpad-acpi full
Fn-F12 hibernate ibm-acpi, thinkpad-acpi full
Fn-Pos1 brightness up tpb additional actions
Fn-End brightness down tpb additional actions
Fn-PageUp toggle thinklight ibm-acpi, tpb additional actions
Fn-Space toggle zoom tpb full
Access IBM help application tpb full
Home open web browser xmodmap, tpb full only iSeries and ext. keyboards
Search open search application xmodmap, tpb full only iSeries and ext. keyboards
Mail open mail application xmodmap, tpb full only iSeries and ext. keyboards
Favorites open favorites xmodmap, tpb full only iSeries and ext. keyboards
Reload reload web page xmodmap, tpb full only iSeries and ext. keyboards
Abort abort loading page xmodmap, tpb full only iSeries and ext. keyboards
Backward previous page xmodmap, tpb full iSeries, ext. keyboards, Thinkpads starting from 2002
Forward next page xmodmap, tpb full iSeries, ext. keyboards, Thinkpads starting from 2002
Volume up volume up tpb additional actions
Volume down volume down tpb additional actions
Volume mute mute volume tpb additional actions
Power shutdown ibm-acpi full triggered on pressing 3secs, but notebook goes off on 5sec press
Display lid blank screen ibm-acpi full
Ultrabay lid announce ultrabay change ibm-acpi full
Dock eject eject from dock ibm-acpi full

ibm-acpi events

events triggered by ibm-acpi for /etc/acpi/events files
key event
Fn-F3 ibm/hotkey HKEY 00000080 00001003
Fn-F4 ibm/hotkey HKEY 00000080 00001004
Fn-F12 ibm/hotkey HKEY 00000080 0000100c
Power button/power PWRF 00000080 xxxxxxxx
Display lid button/lid LID 00000080 xxxxxxxx
Ultrabay eject ibm/bay MSTR 00000003 00000000
Ultrabay inserted ibm/bay MSTR 00000001 00000000

tpb configuration

configuration keywords for tpbrc
key config keyword
Access IBM THINKPAD
Home HOME
Search SEARCH
Mail MAIL
Favorites FAVORITES
Reload RELOAD
Abort ABORT
Backward BACKWARD
Forward FORWARD
Fn FN
Fn-Space CALLBACK (zoom on/off)
Fn-PageUp CALLBACK (thinklight on/off)
Fn-F7 CALLBACK (display lcd/crt/both)
Fn-F8 CALLBACK (expand on/off)
Fn-PageUp CALLBACK (brightness <percent>)
Fn-PageDown CALLBACK (brightness <percent>)
Volume up CALLBACK (volume <percent>)
Volume down CALLBACK (volume <percent>)
Vokume mute CALLBACK (mute on/off)

To all parameter keywords should be assigned the full path to the executables supposed to be started on key press. The exectable provided for the CALLBACK keyword should take the parameters given in parentheses and act according to them. If you want to use xmodmap for the HOME, SEARCH, MAIL, FAVORITES, RELOAD, ABORT, BACKWARD, FORWARD and FN keys you should provide a XEVENTS=off in your tpbrc.

xmodmap configuration

xmodmap enables you to edit the modifier map and keymap tables that are used to translate keycodes into keysyms. Understood? Well, basically it allows you to give the X server a dictionary for the translation of keycodes like "97" into more human readable synonyms like "Home". This way xmodmap allows you to make the special keys of your keyboard known to X applications.

Usually you should write your keycode-keysym associations into the file ~/.Xmodmap. This file is usually read by the X session startup scripts of your system, so that the mappings automatically get included everytime you run the X server.

The ~/.Xmodmap lines for our purpose are in the form of

keycode <keycode> = <keysym>

The following table shows the keycodes generated by the Thinkpad special keys and sensible keysyms to assign them to.

keycodes generated by special keys
key keycode keysym
Backward 234 XF86Back
Forward 233 XF86Forward
Home 178 XF86HomePage
Search 229 XF86Search
Mail 236 XF86Mail
Favorites 230 XF86Favorites
Reload 231 XF86Reload
Abort 232 XF86Stop

(Ofcourse you could also use Fxx keysyms as suggested by a lot of people, but if X offers special keysyms for internet keyboards, why not use them?)

Note: if you are running tpb you might need to add the line XEVENTS=off into your tpbrc to stop it from grabbing the key events and allow them to get through to X instead.

firefox configuration

(First of all thanks go to Ryan Barrett for writing the little howto on his blog.)
To have firefox make use of the browser keys you need to modify one of its files. To do this you will first need to extract it from the browser.jar archive. Do...

$ cd <firefox-directory>/chrome
$ unzip browser.jar

The file of interest is content/browser/browser.xul. Edit it...

$ vi content/browser/browser.xul

Look for the <keyset id="mainKeyset"> section and in there for the lines...

<key id="goBackKb"  keycode="VK_LEFT" command="Browser:Back" modifiers="alt"/>
<key id="goForwardKb"  keycode="VK_RIGHT" command="Browser:Forward" modifiers="alt"/>

Add the following two lines immidiately after them

<key id="goBackKb"  keycode="VK_XF86Back" command="Browser:Back"/>
<key id="goForwardKb"  keycode="VK_XF86Forward" command="Browser:Forward"/>

No save the file and repackage the browser.jar archive...

$ zip -rD0 browser.jar content/browser/

That's it.

pekwm configuration

This is just a small example of what else you can do with your extra keys.
I configured the two browser keys of my T41p to switch workspaces with pekwm, by adding the following two lines to the .pekwm/keys file:

KeyPress = "Mod1 XF86Back" { Actions = "GoToWorkspace prev" }
KeyPress = "Mod1 XF86Forward" { Actions = "GoToWorkspace next" }

(As you can see the XF86..... keysyms are just as universally usable as any others.)