https://www.thinkwiki.org/w/api.php?action=feedcontributions&user=Jespergoll&feedformat=atomThinkWiki - User contributions [en]2024-03-29T09:48:28ZUser contributionsMediaWiki 1.31.12https://www.thinkwiki.org/w/index.php?title=Talk:Thinkpad-acpi&diff=54584Talk:Thinkpad-acpi2013-05-09T18:00:05Z<p>Jespergoll: improved a table</p>
<hr />
<div>== Problem with ACPI key event codes in OpenSuse 12.3 ==<br />
<br />
<br />
The below information was relevant on my Thinkpad Z60m running:<br />
Linux 3.7.10-1.1-desktop<br />
OpenSuse 12.3<br />
KDE 4.10.00 "release 1"<br />
<br />
I am currently running:<br />
Linux 3.7.10-1.4-desktop<br />
OpenSuse 12.3<br />
KDE 4.10.2 "release 1"<br />
and everything said below is still valid.<br />
<br />
<br />
--[[User:Jespergoll|Jespergoll]] ([[User talk:Jespergoll|talk]]) 16:20, 9 May 2013 (CEST)<br />
<br />
<br />
----<br />
<br />
<br />
I upgraded my Thinkpad Z60m to OpenSuse 12.3 shortly after its release on March 13th 2013 - and soon found that my ACPI key handling script ({{path|/usr/lib/acpid/thinkpad_handler}}) was broken.<br />
<br />
Specifically, they key events reported by the ACPI driver were different from what they had been before the upgrade - and so the following information (in {{path|../Documentation/laptops/thinkpad-acpi.txt}}) '''was no longer true on my system''':<br />
<br />
The driver will report HKEY events in the following format:<br />
<br />
ibm/hotkey HKEY 00000080 0000xxxx<br />
<br />
Now, instead, the same HKEY events are generally reported in the following format:<br />
<br />
button/xxxxx YYY 00000080 00000000 K<br />
<br />
- where "xxxxx" is a lowercase name for either the key or the key function, and YYY is a shorter, capitalized version of the same. For example, Fn-F12 ("suspend to disk") is now being reported as:<br />
<br />
button/suspend SUSP 00000080 00000000 K<br />
<br />
I have found one exception to this general rule: Fn-F7 (the video switch button) is now being reported as:<br />
<br />
video/switchmode VMOD 00000080 00000000 K<br />
<br />
<br />
So I had to rewrite my key handler script ({{path|/usr/lib/acpid/thinkpad_handler}}), and even the event mask (found in {{path|/etc/acpi/events/thinkpad}}). My general key event mask now looks like this:<br />
<br />
event=button/.*<br />
action=/usr/lib/acpid/thinkpad_handler "%e"<br />
<br />
To get the video switch script back in shape I created an additional event mask ({{path|/etc/acpi/events/video}}) with the following content:<br />
<br />
event=video/switchmode<br />
action=/usr/lib/acpid/video_handler "%e"<br />
<br />
and moved the video switching routines to a new script: {{path|/usr/lib/acpid/video_handler}}.<br />
<br />
<br />
Here is a list of the key events I have explored, and the event reports they now produce:<br />
<br />
{| {{prettytable}}<br />
|+ selected ACPI key events<br />
! key !! event name !! short name !! constant part !! note<br />
|-<br />
| {{key|Fn}}{{key|F1}} || button/fnf1 || FNF1 || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|F2}} || button/battery || BAT || 00000080 00000000 K || {{footnote|1}}<br />
|-<br />
| {{key|Fn}}{{key|F3}} || button/screenlock || SCRNLCK || 00000080 00000000 K || {{footnote|1}}<br />
|-<br />
| {{key|Fn}}{{key|F4}} || button/sleep || SBTN || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|F5}} || button/wlan || WLAN || 00000080 00000000 K ||<br />
|- <br />
| {{key|Fn}}{{key|F6}} || button/fnf6 || FNF6 || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|F7}} || video/switchmode || VMOD || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|F8}} || button/zoom || ZOOM || 00000080 00000000 K || {{footnote|2}}<br />
|- <br />
| {{key|Fn}}{{key|F9}} || button/f24 || F24 || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|F10}} || (not reported to handler) || ||<br />
|-<br />
| {{key|Fn}}{{key|F11}} || button/fnf11 || FF11 || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|F12}} || button/suspend || SUSP || 00000080 00000000 K ||<br />
|-<br />
| {{key|Fn}}{{key|Space}} || button/zoom || ZOOM || 00000080 00000000 K || {{footnote|2}}<br />
|-<br />
| {{ibmkey|ThinkVantage|#495988}} || button/prog1 || PROG1 || 00000080 00000000 K ||<br />
|}<br />
<br />
{{footnotes|<br />
#Fn-F2 and Fn-F3 seem to have become mixed up in the driver. On my machine at least, Fn-F2 is "lock" and Fn-F3 is "battery".<br />
#Please note that Fn-F8 and Fn-Space now produce identical event reports - so there is no way to distinguish one from the other.<br />
}}</div>Jespergollhttps://www.thinkwiki.org/w/index.php?title=How_to_get_special_keys_to_work&diff=54583How to get special keys to work2013-05-09T17:10:13Z<p>Jespergoll: Added a note pointing to a description of some recent alterations to key event codes.</p>
<hr />
<div>==Overview==<br />
The following table gives an overview over the special keys found on ThinkPads and what is needed to make them work.<br />
{| {{prettytable}}<br />
! key !! standard function{{footnote|1}} !! tools supporting key{{footnote|2}} !! configurability{{footnote|3}} !! remarks<br />
|-<br />
| {{key|Fn}} || - || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || on release without completed key combination<br />
|-<br />
| {{key|Fn}}{{key|F1}} || - || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|F2}} || lock screen || [[thinkpad-acpi]] || full || in models from T/X/Z 60 onwards<br />
|-<br />
| {{key|Fn}}{{key|F3}} || blank screen || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|F4}} || suspend to ram || [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the thinkpad-acpi hotkey mask<br />
|-<br />
| {{key|Fn}}{{key|F5}} || switch bluetooth || [[thinkpad-acpi]] || full || in models starting from 2002<br />
|-<br />
| {{key|Fn}}{{key|F6}} || Video conference || || || Starting with the T400s (icon of a camera and a headset)<br />
|-<br />
| {{key|Fn}}{{key|F7}} || toggle display || [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions || [[Sample Fn-F7 script]]<br />
|-<br />
| {{key|Fn}}{{key|F8}} || toggle trackpoint/touchpad || [[thinkpad-acpi]], [[#tpb configuration|tpb]] || additional actions ||<br />
|-<br />
| {{key|Fn}}{{key|F9}} || eject from dock || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|F10}} || - || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|F11}} || - || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|F12}} || hibernate || [[thinkpad-acpi]] || full || may generate ACPI event when not enabled in the thinkpad-acpi hotkey mask<br />
|-<br />
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || brightness up || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||<br />
|-<br />
| {{key|Fn}}{{key|End}} || brightness down || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||<br />
|-<br />
| {{key|Fn}}{{key|PageUp}} || toggle thinklight || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||<br />
|-<br />
| {{key|Fn}}{{key|Space}} || toggle zoom || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|Ins}} || - || [[thinkpad-acpi]]|| full ||<br />
|-<br />
| {{key|Fn}}{{key|Del}} || - || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|Fn}}{{key|Backspace}} || - || [[thinkpad-acpi]] || full ||<br />
|-<br />
| {{key|NumLock}} || - || [[#xmodmap configuration|xmodmap]] || make working ||<br />
|-<br />
| {{key|Windows}} || - || [[#xmodmap configuration|xmodmap]] || remapping ||<br />
|-<br />
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} or {{ibmkey|ThinkVantage|#495988}} || help application || [[thinkpad-acpi]],[[#tpb configuration|tpb]], [[KMilo]] || full ||<br />
|-<br />
| {{ibmkey|Home|#494949}} || open web browser || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards<br />
|-<br />
| {{ibmkey|Search|#494949}} || open search application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards<br />
|-<br />
| {{ibmkey|Mail|#494949}} || open mail application || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]], [[KMilo]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards<br />
|-<br />
| {{ibmkey|Favorites|#494949}} || open favorites || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards<br />
|-<br />
| {{ibmkey|Reload|#494949}} || reload web page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards<br />
|-<br />
| {{ibmkey|Abort|#494949}} || abort loading page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || only {{A30}}, {{A30p}}, {{A31}}, {{A31p}} and ext. keyboards<br />
|-<br />
| {{ibmkey|Backward|#494949}} || previous page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || ext. keyboards and ThinkPads starting from 2002<br />
|-<br />
| {{ibmkey|Forward|#494949}} || next page || [[#xmodmap configuration|xmodmap]], [[#tpb configuration|tpb]] || full || ext. keyboards and ThinkPads starting from 2002<br />
|-<br />
| {{ibmkey|Volume up|#494949}} || volume up || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||<br />
|-<br />
| {{ibmkey|Volume down|#494949}} || volume down || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||<br />
|-<br />
| {{ibmkey|Volume mute|#494949}} || mute volume || [[thinkpad-acpi]], [[#tpb configuration|tpb]], [[KMilo]] || additional actions ||<br />
|-<br />
| {{ibmkey|Microphone mute|#494949}} || Microphone volume || || || Starting with the T400s<br />
|-<br />
| {{ibmkey|Play/Pause|#494949}} || start/pause playback || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Down)<br />
|-<br />
| {{ibmkey|Stop|#494949}} || stop playback || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Up)<br />
|-<br />
| {{ibmkey|Next|#494949}} || play next || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Right)<br />
|-<br />
| {{ibmkey|Previous|#494949}} || play previous || [[#xmodmap configuration|xmodmap]] || full || {{X60s}} (Fn+Arrow Left)<br />
|-<br />
| {{ibmkey|Power|#494949}} || shutdown || [[thinkpad-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press<br />
|-<br />
| Display lid || blank screen || acpi video || full ||<br />
|-<br />
| Ultrabay eject || announce ultrabay change || acpi bay || full ||<br />
|-<br />
| Dock eject || eject from dock || acpi dock || full ||<br />
|-<br />
| {{ibmkey|Tablet power|#494949}} || shutdown || [[thinkpad-acpi]] || full || triggered on pressing 3secs, but notebook goes off on 5sec press<br />
|-<br />
| {{ibmkey|Tablet orientation|#494949}} || rotates screen || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|-<br />
| {{ibmkey|Tablet shortcut|#494949}} || shortcut menu || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|-<br />
| {{ibmkey|Tablet Esc|#494949}} || esc key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|-<br />
| {{ibmkey|Tablet Enter|#494949}} || enter key || [[#mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|-<br />
| {{ibmkey|Tablet Up|#494949}} || up key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|-<br />
| {{ibmkey|Tablet Down|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|-<br />
| {{ibmkey|Tablet (unlabeled)|#494949}} || down key || [[#Mapping keys with setkeycodes|setkeycodes]] || full ||<br />
|}<br />
<br />
For completeness, note that the WiFi enable/disable switch is located (on the X61 and other models that have it) just under the front edge of the base of the machine. You should see a small horizontal slider switch. Enable by sliding it rightwards, disable by sliding it leftwards.<br />
<br />
Tablet buttons vary with model. See [[Tablet Hardware Buttons]].<br />
<br />
==Triggering key events==<br />
<br />
===thinkpad_acpi events===<br />
The thinkpad_acpi driver should automatically select an appropriate mask for your machine.<br />
But on a rare occasions you might need to change the hotkey mask for key events to happen. In that case,<br />
read the recommended hotkey_mask from hotkey_recommended_mask, set the extra bits you need, and write<br />
the result to hotkey_mask. These files (actually, "sysfs attributes") can be found on {{path|sys/devices/platform/thinkpad_acpi}}<br />
<br />
These events can be used to configure HAL or [[How to configure acpid|acpid]].<br />
<br />
{{WARN|The below list of ACPI key events seems to have been invalidated on some platforms by a recent update (March 2013) - for details, see [[Talk:Thinkpad-acpi#Problem_with_ACPI_key_event_codes_in_OpenSuse_12.3|Problem with ACPI key event codes in OpenSuse 12.3]].}}<br />
<br />
{| {{prettytable}}<br />
|+ events triggered by [[thinkpad-acpi]]. May vary on different models.<br />
! key !! acpi event || IBM ThinkPad hal event || Lenovo ThinkPad hal event<br />
|-<br />
| {{key|Fn}}{{key|F1}} || ibm/hotkey HKEY 00000080 00001001 || ||<br />
|-<br />
| {{key|Fn}}{{key|F2}} || ibm/hotkey HKEY 00000080 00001002 || 0x01:battery || 0x01:screenlock<br />
|-<br />
| {{key|Fn}}{{key|F3}} || ibm/hotkey HKEY 00000080 00001003 || 0x02:screenlock || 0x02:battery<br />
|-<br />
| {{key|Fn}}{{key|F4}} || ibm/hotkey HKEY 00000080 00001004 || 0x03:sleep || 0x03:sleep<br />
|-<br />
| {{key|Fn}}{{key|F5}} || ibm/hotkey HKEY 00000080 00001005 || 0x04:radio || 0x04:radio<br />
|- <br />
| {{key|Fn}}{{key|F6}} || ibm/hotkey HKEY 00000080 00001006 || ||<br />
|-<br />
| {{key|Fn}}{{key|F7}} || ibm/hotkey HKEY 00000080 00001007 || 0x06:switchvideomode || 0x06:switchvideomode<br />
|-<br />
| {{key|Fn}}{{key|F8}} || ibm/hotkey HKEY 00000080 00001008 || 0x07:zoom || 0x07:f22<br />
|- <br />
| {{key|Fn}}{{key|F9}} || ibm/hotkey HKEY 00000080 00001009 || 0x08:f24 || 0x08:f24<br />
|-<br />
| {{key|Fn}}{{key|F10}} || ibm/hotkey HKEY 00000080 0000100a || ||<br />
|-<br />
| {{key|Fn}}{{key|F11}} || ibm/hotkey HKEY 00000080 0000100b || ||<br />
|-<br />
| {{key|Fn}}{{key|F12}} || ibm/hotkey HKEY 00000080 0000100c || 0x0b:suspend || 0x0b:suspend<br />
|-<br />
| {{key|Fn}}{{key|Backspace}} || ibm/hotkey HKEY 00000080 0000100d || ||<br />
|-<br />
| {{key|Fn}}{{key|Ins}} || ibm/hotkey HKEY 00000080 0000100e || ||<br />
|-<br />
| {{key|Fn}}{{key|Del}} || ibm/hotkey HKEY 00000080 0000100f || ||<br />
|-<br />
| {{key|Fn}}{{key|Home}}/{{key|Fn}}{{key|Pos1}} || ibm/hotkey HKEY 00000080 00001010 || 0x0f:brightnessup || 0x0f:brightnessup<br />
|-<br />
| {{key|Fn}}{{key|End}} || ibm/hotkey HKEY 00000080 00001011 || 0x10:brightnessdown || 0x10:brightnessdown<br />
|-<br />
| {{key|Fn}}{{key|PgUp}} || ibm/hotkey HKEY 00000080 00001012 || 0x11:kbdillumtoggle || 0x11:kbdillumtoggle<br />
|-<br />
| {{key|Fn}}{{key|Space}} || ibm/hotkey HKEY 00000080 00001014 || 0x13:zoom || 0x13:zoom<br />
|-<br />
| {{ibmkey|Volume up|#494949}}|| ibm/hotkey HKEY 00000080 00001015 || 0x14:volumeup || 0x14:volumeup<br />
|-<br />
| {{ibmkey|Volume down|#494949}} || ibm/hotkey HKEY 00000080 00001016 || 0x15:volumedown || 0x15:volumedown<br />
|-<br />
| {{ibmkey|Volume mute|#494949}} || ibm/hotkey HKEY 00000080 00001017 || 0x16:mute || 0x16:mute<br />
|-<br />
| {{ibmkey|Microphone mute|#494949}} || ibm/hotkey HKEY 00000080 0000101b || ||<br />
|-<br />
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} or {{ibmkey|ThinkVantage|#495988}} || ibm/hotkey HKEY 00000080 00001018 || 0x17:prog1 || 0x17:prog1<br />
|-<br />
| Ultrabay eject || ibm/bay MSTR 00000003 00000000 || ||<br />
|-<br />
| Ultrabay inserted || ibm/bay MSTR 00000001 00000000 || ||<br />
|-<br />
| Dock eject || ibm/dock GDCK 00000003 00000001 || ||<br />
|-<br />
| Wireless switch || ibm/hotkey HKEY 00000080 00007000 || ||<br />
|}<br />
<br />
By disassembling and editing the DSDT, more events can be added. HKEY events are triggered by calls to the MKHQ function, e.g. <tt>\_SB.PCI0.LPC.EC.HKEY.MHKQ(0×1007)</tt> will trigger "ibm/hotkey HKEY 00000080 00001007". Most of these can be found in <tt>_Qxx</tt> methods within the DSDT, which are executed on embedded controller events, e.g. _Q10 is triggered by pressing Fn-F7. You can add a call to MKHQ into an existing <tt>_Qxx</tt> method to get it recognized by thinkpad-acpi as well as creating new <tt>_Qxx</tt> methods, which if you're lucky will correspond to an EC event that IBM never used (e.g. A 770 will send Fn-Home/End/PgUp/PgDn to thinkpad-acpi if hacked in this fashion). For example, [http://www.wormnet.eu/ibm-g40/morebuttons.dsl this is a modified block of DSDT for a G40].<br />
<br />
=== ACPI events from the <tt>button</tt> module===<br />
<br />
A few keys can generate ACPI events that result from the <tt>button</tt> kernel module, as long as they are masked off in the <tt>thinkpad-acpi</tt> hotkey's mask or the hotkey function of the latter module is disabled.<br />
<br />
If you want the ThinkPad's BIOS and ACPI methods to know about these keys being pressed, you probably want to leave them masked out from thinkpad-acpi, and use their non-HKEY events listed below, instead.<br />
<br />
{| {{prettytable}}<br />
|+ events triggered by ACPI when hotkey is masked out or disabled. <br />
! key !! event !! T60 event<br />
|-<br />
| {{ibmkey|Power|#494949}} || button/power PWRF 00000080 xxxxxxxx || button/power PWRF 00000080 00000001<br />
|-<br />
| {{key|Fn}}{{key|F4}} || button/sleep SLPB 00000080 00000001 || button/sleep SLPB 00000080 00000001<br />
|-<br />
| Display lid || button/lid LID 00000080 xxxxxxxx || button/lid LID 00000080 00000001<br />
|}<br />
<br />
===Configuration using HAL===<br />
<br />
Modern distributions like Ubuntu 8.10 and Fedora 10 use HAL to configure the kernel input devices. Xorg in turn gets these key events through the evdev driver and will no longer try to take control of the input devices away from the kernel.<br />
<br />
But before you get started on this you should make sure you have all the updates applied from your distro vendor as both Ubuntu 8.10 and Fedora 10 require some additional fixes that you might need.<br />
====Xorg problems====<br />
You may find that by default some buttons will work in Xorg and others will not (e.g. Fn-Space). The reason for this is that Xorg is limited to 255 different key codes, and some keys are mapped to key codes that are out of range for Xorg. The Xorg developers are aware of this issue and plan to fix it in XKB2. Unfortunately support for XKB2 has slipped and is now planned for Xorg 1.8, sometime in 2010.<br />
<br />
{{HINT|You can get Fn-Space working via ACPI events. Here is a practical [http://www.thinkwiki.org/wiki/Installing_Ubuntu_10.04_(Lucid_Lynx)_on_a_ThinkPad_Z61m#Make_Fn-Space_.28Screen_Magnify.29_work HOWTO] for Ubuntu 10.04 Lucid}} <br />
<br />
Default HAL config files are located in {{path|/usr/share/hal/fdi}}. If you create any custom files you should instead place them in {{path|/etc/hal/fdi}} to prevent them from getting overwritten by the next hal-info package update of your distribution.<br />
<br />
You can see for instance the mapping between {{path|/usr/share/hal/fdi/information/10freedesktop/30-keymap-module-thinkpad-acpi.fdi}} and that of the kernel [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=include/linux/input.h;hb=HEAD input.h] header file.<br />
<br />
keyboard events defined in input.h in the 0x100 range and above will be ignored by current Xorg. If you want to work around this you can change the hal config file such that for instance the Fn-F5 key no longer maps to '''radio''' (0x181) but to '''wlan''' (238) or '''bluetooth''' (237).<br />
<br />
Have a look at the HAL documentation for samples on how to configure your own events [http://hal.freedesktop.org/quirk/quirk-keymap-index.html].<br />
<br />
To check if a key is being handled by Xorg, start xev and press the key. If you do not see any output from the keypress it is not handled. If it is handled you can configure the key in Gnome with gnome-keybinding-properties (kde??).<br />
<br />
====bypassing Xorg====<br />
Since the keys are handled by the kernel and passed through hal, we can bypass Xorg and have a key run a specific task.<br />
This is useful if Xorg cannot handle the key (out of range, or X doesn't<br />
matter this input key), or if your not running X. This can be done with the<br />
'''halevt''' program (located at [http://www.nongnu.org/halevt|http://www.nongnu.org/halevt] ; for Debian systems, use a version >= 0.1.5-1). This program can react to some events detected by HAL such a special key press. For example, to run a custom script when Fn-F5 (Radio toggle) is pressed, you could put a stanza in halevt's configuration file ('''/etc/halevt/halevt.xml''', in XML format) :<br />
<br />
<nowiki><br />
<halevt:Device match="hal.info.category = input"><br />
<!-- Warning: /etc/sudoers must be configured to let 'halevt' user<br />
runs the given command ! --><br />
<halevt:Condition name="ButtonPressed" value="wlan" exec="sudo /usr/local/sbin/toggle_wlan"/><br />
</halevt:Device><br />
</nowiki><br />
<br />
Here, '''sudo''' is used as the halevt daemon runs with its own user, which don't have required rights to do the work in the custom script ''/usr/local/sbin/toggle_wlan'', so in ''/etc/sudoers'', we have :<br />
<br />
halevt ALL = NOPASSWD: /usr/local/sbin/toggle_wlan<br />
<br />
Be careful when writing halevt configuration, as the daemon isn't very verbose about what it does or not : you don't get error messages when command run fails…<br />
<br />
===inputlirc configuration===<br />
<br />
An alternative to halevt is inputlirc [http://ajoute.org/wiki/doc/linux/inputlirc]. After installation of the packages inputlirc [http://packages.debian.org/search?keywords=inputlirc] and lirc, you can test it with the irw command. To run custom scripts you need a configuration for the irexec daemon ('''/etc/lirc/lircrc''') :<br />
<br />
<nowiki><br />
begin<br />
prog = irexec<br />
button = KEY_RADIO<br />
config = /etc/acpi/wireless.sh<br />
end<br />
<br />
begin<br />
prog = irexec<br />
button = KEY_SCREENLOCK<br />
config = /etc/acpi/thinkpad-lockorbattery.sh<br />
end<br />
</nowiki><br />
<br />
===tpb configuration===<br />
{| {{prettytable}}<br />
|+ configuration keywords for [[tpb]] (to put in {{path|/etc/tpbrc}})<br />
! key !! config keyword<br />
|-<br />
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || THINKPAD<br />
|-<br />
| {{ibmkey|Home|#494949}} || HOME<br />
|-<br />
| {{ibmkey|Search|#494949}} || SEARCH<br />
|-<br />
| {{ibmkey|Mail|#494949}} || MAIL<br />
|-<br />
| {{ibmkey|Favorites|#494949}} || FAVORITES<br />
|-<br />
| {{ibmkey|Reload|#494949}} || RELOAD<br />
|-<br />
| {{ibmkey|Abort|#494949}} || ABORT<br />
|-<br />
| {{ibmkey|Backward|#494949}} || BACKWARD<br />
|-<br />
| {{ibmkey|Forward|#494949}} || FORWARD<br />
|-<br />
| {{key|Fn}} || FN<br />
|-<br />
| {{key|Fn}}{{key|Space}} || CALLBACK (zoom on/off)<br />
|-<br />
| {{key|Fn}}{{key|PageUp}} || CALLBACK (thinklight on/off)<br />
|-<br />
| {{key|Fn}}{{key|F7}} || CALLBACK (display lcd/crt/both)<br />
|-<br />
| {{key|Fn}}{{key|F8}} || CALLBACK (expand on/off)<br />
|-<br />
| {{key|Fn}}{{key|Home}} / {{key|Fn}}{{key|Pos1}} || CALLBACK (brightness <percent>)<br />
|-<br />
| {{key|Fn}}{{key|End}} || CALLBACK (brightness <percent>)<br />
|-<br />
| {{ibmkey|Volume up|#494949}} || CALLBACK (volume <percent>)<br />
|-<br />
| {{ibmkey|Volume down|#494949}} || CALLBACK (volume <percent>)<br />
|-<br />
| {{ibmkey|Volume mute|#494949}} || CALLBACK (mute on/off)<br />
|}<br />
<br />
To all parameter keywords should be assigned the full path to the executables supposed to be started on key press.<br />
The exectable provided for the CALLBACK keyword should take the parameters given in parentheses and act according to them.<br />
If you want to use xmodmap for the HOME, SEARCH, MAIL, FAVORITES, RELOAD, ABORT, BACKWARD, FORWARD and FN keys you should<br />
provide a <tt>XEVENTS OFF</tt> in your {{path|/etc/tpbrc}}. <br />
You can use an appropriate executable to [[How to inject fake keystrokes|inject fake keystrokes]].<br />
<br />
For Debian users, tpb is started from {{path|/etc/X11/Xsession.d/90tpb}}.<br />
<br />
'''Sound Button configuration'''<br />
<br />
''Note: Tested on T60p with Ubuntu 6.06 LTS''<br />
<br />
Most Thinkpads have a hardware sound mixer, thus the volumes buttons should work without configuration. However, this change is not reflected in the software mixer. tpb has a switch to enable software mixer support via OSS. The manual recommends this only for devices without a hardware mixer, but it also works for other hadware mixer enabled devices, even with the ALSA system. Just put MIXER ON in your {{path|/etc/tpbrc}} file and you can see the effect immediately in any ALSA mixer (e.g. kmix). For this to work you need write permissions to {{path|/dev/nvram}}.<br />
<br />
''Note: Tested on X21 with Ubuntu 6.06 LTS''<br />
<br />
On the ThinkPad X21 (and maybe some other older models) ACPI causes problems with tpb. On an X21 using acpi the volume buttons would work occasionally, and the OSD for tpb functions would rarely work. If a volume buttons was pressed too often, sometimes the computer would enter a low power (unplugged state) and would require a reboot. The solution is to use APM instead of ACPI. Instructions can be found in [[How_to_make_APM_work]].<br />
<br />
===KMilo configuration===<br />
The programs to be executed by [[KMilo]] are configured via the KDE Control Center (<tt>kcontrol</tt>), under <tt>System Administration --> IBM Thinkpad Laptop</tt>. Note that you can use appropriate commands to [[How to inject fake keystrokes|inject fake keystrokes]].<br />
<br />
===xmodmap configuration===<br />
xmodmap enables you to edit the modifier map and keymap tables that are used to translate keycodes into keysyms.<br />
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.<br />
<br />
To discover the keycode that a certain keypress produces, use the tool {{cmduser|xev}} <br />
<br />
Usually you should write your keycode-keysym associations into the file {{path|~/.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.<br />
<br />
The {{path|~/.Xmodmap}} lines for our purpose are in the form of<br />
keycode <keycode> = <keysym><br />
<br />
Load the assocation using the command<br />
<br />
{{cmduser|xmodmap ~/.Xmodmap}} <br />
<br />
(some configurations do this automatically upon X startup). <br />
<br />
The following table shows the keycodes generated by the ThinkPad special keys and sensible keysyms to assign them to.<br />
{| {{prettytable}}<br />
|+ keycodes and recommended keysyms<br />
! key !! keycode !! keysym<br />
|-<br />
| {{ibmkey|Access IBM|#495988}} or {{ibmkey|ThinkPad|#494949}} || 159 || XF86LaunchA<br />
|-<br />
| {{ibmkey|Backward|#494949}} || 234 || XF86Back or F19<br />
|-<br />
| {{ibmkey|Forward|#494949}} || 233 || XF86Forward or F20<br />
|-<br />
| {{ibmkey|Play/Pause|#494949}} || 162 || XF86AudioPlay<br />
|-<br />
| {{ibmkey|Stop|#494949}} || 164 || XF86AudioStop<br />
|-<br />
| {{ibmkey|Next|#494949}} || 153 || XF86AudioNext<br />
|-<br />
| {{ibmkey|Previous|#494949}} || 144 || XF86AudioPrev<br />
|-<br />
<br />
<br />
| {{ibmkey|Home|#494949}} || 178 || XF86HomePage<br />
|-<br />
| {{ibmkey|Search|#494949}} || 229 || XF86Search<br />
|-<br />
| {{ibmkey|Mail|#494949}} || 236 || XF86Mail<br />
|-<br />
| {{ibmkey|Favorites|#494949}} || 230 || XF86AddFavorite or XF86Favorites<br />
|-<br />
| {{ibmkey|Reload|#494949}} || 231 || XF86Reload<br />
|-<br />
| {{ibmkey|Abort|#494949}} || 232 || XF86Stop<br />
|-<br />
| {{key|Fn}} || 227 || F35<br />
|}<br />
<br />
Note: You can also use xkeycaps (an X tool to display and edit the X keyboard mapping) to generate proper .Xmodmap.<br />
<br />
Note: if you are running [[tpb]] you might need to add the line <tt>XEVENTS=off</tt> into your tpbrc to stop it from grabbing the key events and allow them to get through to X instead. See [[http://www.thinkwiki.org/wiki/Tpb]] for more detailed instruction on how to use tpb and xmodmap.<br />
<br />
Note: XF86Forward and XF86Back do not work correctly in Firefox. You may want to map them to F19 and F20 instead if you use Firefox.<br />
<br />
Note: The "XF86AudioPlay" etc. just works with a few programs. To make it work with more multimedia programs you have map the key to use something like [http://www.kde-apps.org/content/show.php/ReMoot?content=63140 ReMoot]. ReMoot is a command line wrapper that control 18 of the most common multimedia applications. <br />
<br />
=====Enabling the Windows and Menu Keys=====<br />
On some systems the Windows and Menu keys may not be recognized. You can enable then by<br />
making the following changes:<br />
<br />
keycode 115 = F13<br />
keycode 227 = F35<br />
<br />
F13 and F35 are used for the Windows and and Menu keys respectively. Labelling keycpode 227 as "Menu" may conflict with the right-mouse-click event.<br />
<br />
=====Using Caps Lock as Super L (Windows key)=====<br />
You can easily use Caps Lock as Win key by adding the following in your ~/.Xmodmap:<br />
! No Caps Lock<br />
clear lock<br />
! Caps Lock as Win key<br />
add mod4 = Caps_Lock<br />
=====NumLock=====<br />
On the ThinkPad {{600}}, {{T20}}, {{T21}}, {{T22}}, {{T30}}, {{X20}}, {{X21}}, {{X31}}, {{X40}}, {{T42p}}, {{T43}}, {{R51}}, {{R52}} and possibly other models, X does not recognize the keycode for {{key|NumLk}} = {{key|Shift}}+{{key|ScrLk}}. To fix this, add the following to {{path|~/.Xmodmap}} in your home directory or {{path|/etc/X11/Xmodmap}} and run <tt>xmodmap</tt>, ex: <tt>xmodmap ~/.Xmodmap</tt>:<br />
keycode 77 = Num_Lock<br />
<br />
The following might work better for you:<br />
keycode 77 = Num_Lock Num_Lock<br />
because you will only get keycode 77 together with Shift (at least on the {{T43}})<br />
<br />
This configuration also enables the respective LED.<br />
<br />
Please note, pressing the {{key|Shift}}+{{key|ScrLk}} key combination, without first following the above configuration, will start an accessibility feature, which will allow the numeric keypad to maneuver the mouse pointer. Starting this accessibility feature and subsequently running xmodmap, as described above, results in the accessibility feature and the numeric lock LED functioning simultaneously. As such, the above configuration should be completed before the accessibility feature is started in order to produce numbers.<br />
======T60 (and possibly others)======<br />
It seems that on the T60, PrtSc, ScrLk and Pause all generate the correct keycodes, however Fn-PrtSc (labelled as SysRq) generates keycode 64 (Alt_L) followed by the expected 111 (Sys_Req) on down and the same thing in the opposite order on release. Fn-ScrLk (labelled as NmLk) does indeed toggle the Numlock, but only seems to register as an X event the first time it is engaged. The above solution does not appear to work. This is perhaps because the Numlock toggle is built into the firmware rather than controlled by the kernel. Finally, Fn-Pause (labelled as Break) generates keycode 37 (Control_L) followed by the expected keycode 110 (Break) on down and the same thing in reverse order on release.<br />
<br />
=====NumPad (KeyPad) keys access by a key combination=====<br />
The current state is that you have to switch NumLock '''on''' via {{key|Fn}}+{{key|ScrLk}} and then e.g. type {{key|u}} to get a {{key|KP_4}} (NumPad 4). To get back to normal keyboard, you have to type {{key|Fn}}+{{key|ScrLk}} again.<br />
<br />
Some people (including me) are missing on recent Thinkpads the option to have Fn as a modifier key to access the NumPad instead, i.e. and e.g. {{key|Fn}}+{{key|u}} gives you {{key|KP_4}}.<br />
<br />
There is currently no way to make this work in a simple way (pleeeease correct me if I am wrong!), though there is a work-around. Instead of using {{key|Fn}} for accessing the NumPad, {{key|CapsLock}} can get this function by being mapped as Mode_switch (the {{key|AltGr}} on international keyboards). The {{key|Fn}} can be remapped to be Caps_Lock - while at the same time retaining its function to access the special laptop functions (e.g. {{key|Fn}}+{{key|F4}} for sleep}}, by using .Xmodmap.<br />
<br />
So on my {{R60}} running fvwm@{{Slackware}} 12.1 the .Xmodmap would look like this:<br />
<br />
! Make the forward and back buttons work<br />
keycode 233 = XF86Forward<br />
keycode 234 = XF86Back<br />
! Make the WIN key to Super modifier<br />
keycode 115 = Super_L<br />
! Set the Caps_Lock physical key to Mode_switch (like AltGr on intl. keyboards)<br />
keycode 66 = Mode_switch<br />
! Set the Fn key to work as Caps_Lock now. The special key combos like Fn-F4 for "sleep" still work then<br />
keycode 227 = Caps_Lock<br />
clear lock<br />
add lock = Caps_Lock<br />
! Now we activate those new keys. Find some free mod slots (xmodmap) and put them there.<br />
clear mod4<br />
clear mod5<br />
add mod4 = Super_L<br />
add mod3 = Mode_switch<br />
! It's time to add the keypad keys to the third position of the key definition (pure shift mode_switch shift+mode_switch)<br />
keycode 16 = 7 ampersand KP_7<br />
keycode 17 = 8 asterisk KP_8<br />
keycode 18 = 9 parenleft KP_9<br />
keycode 19 = 0 parenright KP_Divide<br />
keycode 30 = u U KP_4<br />
keycode 31 = i I KP_5<br />
keycode 32 = o O KP_6<br />
keycode 33 = p P KP_Multiply<br />
keycode 44 = j J KP_1<br />
keycode 45 = k K KP_2<br />
keycode 46 = l L KP_3<br />
keycode 47 = semicolon colon KP_Subtract<br />
keycode 58 = m M KP_0<br />
! ... I have to use the coma key, too, on the keypad...so I set it to be F20 (which is not existing on normal keyboards and thus is free... check for side effects in programmes accepting F12+ keys!)<br />
keycode 59 = comma less F20 <br />
keycode 60 = period greater KP_Decimal <br />
keycode 61 = slash question KP_Add<br />
<br />
{{WARN|Your keycodes might be different as well as your '''mod''#''''' settings.}}<br />
Use {{cmduser|xmodmap}} and {{cmduser|xmodmap -pke}} to check your ModMap, and the tool {{cmduser|xev}} to obtain your exact key codes.<br />
<br />
===Mapping keys with setkeycodes===<br />
You can use the setkeycodes command to remap certain keys. I.e. you can use {{cmdroot|setkeycodes 6e 109 6d 104 69 28 6b 1}} to map the Tablets Up and Down keys to the standard PageUp and PageDown keys and Tablet Escape and Enter to their respective keys.<br />
<br />
The following table shows the scancodes generated by the ThinkPad keys. They vary with model - see [[Tablet Hardware Buttons]].<br />
{| {{prettytable}}<br />
|+ scancodes<br />
! key !! scancode<br />
|-<br />
| {{ibmkey|Tablet orientation|#494949}} || 0x6c<br />
|-<br />
| {{ibmkey|Tablet Shortcut|#494949}} || 0x68<br />
|-<br />
| {{ibmkey|Tablet Esc|#494949}} || 0x6b<br />
|-<br />
| {{ibmkey|Tablet Enter|#494949}} || 0x69<br />
|-<br />
| {{ibmkey|Tablet Up|#494949}} || 0x6d<br />
|-<br />
| {{ibmkey|Tablet Down|#494949}} || 0x6e<br />
|-<br />
| {{ibmkey|Tablet (unlabeled)|#494949}} || 0x67<br />
|}<br />
<br />
===acpi_fakekey===<br />
You can turn acpi events into user-level xevents by putting <tt>acpi_fakekey</tt> commands into the acpi action scripts. There are several layers involved in using acpi keys in this way, so I'll go through the example of using the ThinkVantage button to open xmms.<br />
<br />
My ThinkVantage button generates an '''acpi event''' "ibm/hotkey HKEY 00000080 00001018", so we have the event file <tt>/etc/acpi/events/ThinkVantage</tt> for it which executes the script <tt>/etc/acpi/actions/fakekey-macro.sh</tt>. <br />
<pre><br />
event=ibm/hotkey HKEY 00000080 00001018<br />
action=/etc/acpi/actions/fakekey-macro.sh<br />
</pre><br />
In turn, the executable <tt>/etc/acpi/actions/fakekey-macro.sh</tt> script calls acpi_fakekey with the '''key number''' defined in <tt>/usr/share/acpi-support/key-constants</tt> as $KEY_MACRO which is 112 (you could just as well choose an other key number, just make sure that it doesn't belong to something else like the "j" key or something). <br />
<pre><br />
#!/bin/sh<br />
. /usr/share/acpi-support/key-constants<br />
acpi_fakekey $KEY_MACRO <br />
</pre><br />
I have no idea how this actually corresponds to which xevent is generated, so I can find out out by running the program <tt>xev</tt> and hitting the ThinkVantage button while the mouse is in the <tt>xev</tt> window (remember to <tt>/etc/init.d/acpid restart</tt> first if you just created the <tt>/etc/acpi/events/ThinkVantage</tt> file). I get something popping up in the terminal where I ran xev that looks like this:<br />
<pre><br />
KeyPress event, serial 30, synthetic NO, window 0x2800001,<br />
root 0x6a, subw 0x0, time 2000522842, (138,83), root:(781,500),<br />
state 0x0, keycode 239 (keysym 0x0, NoSymbol), same_screen YES,<br />
XLookupString gives 0 bytes: <br />
XmbLookupString gives 0 bytes: <br />
XFilterEvent returns: False<br />
<br />
KeyRelease event, serial 30, synthetic NO, window 0x2800001,<br />
root 0x6a, subw 0x0, time 2000522842, (138,83), root:(781,500),<br />
state 0x0, keycode 239 (keysym 0x0, NoSymbol), same_screen YES,<br />
XLookupString gives 0 bytes: <br />
XFilterEvent returns: False<br />
</pre><br />
This tells me that the <tt>acpi_fakekey 112</tt> as executed by hitting the ThinkVantage button generates KeyPress event followed by a KeyRelease event with '''keycode''' 239 and that this keycode has been assigned no corresponding '''keysym'''. Thus, I am free to assign the keycode to any keysym I want. You can find a list of available keysyms in <tt>/usr/share/X11/XKeysymDB</tt>. Again try and pick one that is not likely to have already been taken by something, such as <tt>XF86LaunchA</tt>. To assign this keysym to keycode 239, you can either edit ~/.Xmodmap on an individual user basis, or edit the systemwide <tt>/etc/X11/Xmodmap</tt> file to contain the line<br />
<pre><br />
keycode 239 = XF86LaunchA<br />
</pre><br />
If you choose to go with the former, you may need to run <tt>xmodmap ~/.Xmodmap</tt> for every login session in order to read in your ~/.Xmodmap file if your window manager does not do it for you. Regardless of which option you choose, you can run <tt>xmodmap <file></tt> to read in the updated Xmodmap file without logging out and logging back in.<br />
<br />
You should now find that hitting the ThinkVantage button creates the following output from <tt>xev</tt>:<br />
<pre><br />
KeyPress event, serial 55, synthetic NO, window 0x2800001,<br />
root 0x6a, subw 0x0, time 2001286078, (0,106), root:(643,523),<br />
state 0x0, keycode 239 (keysym 0x1008ff4a, XF86LaunchA), same_screen YES,<br />
XLookupString gives 0 bytes: <br />
XmbLookupString gives 0 bytes: <br />
XFilterEvent returns: False<br />
<br />
KeyRelease event, serial 55, synthetic NO, window 0x2800001,<br />
root 0x6a, subw 0x0, time 2001286078, (0,106), root:(643,523),<br />
state 0x0, keycode 239 (keysym 0x1008ff4a, XF86LaunchA), same_screen YES,<br />
XLookupString gives 0 bytes: <br />
XFilterEvent returns: False<br />
</pre><br />
Note the change of <tt>(keysym 0x0, NoSymbol)</tt> to <tt>(keysym 0x1008ff4a, XF86LaunchA)</tt>.<br />
<br />
You're now ready to map <tt>XF86LaunchA</tt> to executing xmms. This is highly dependent on what keygrabber you decide to use. For openbox, I edit my <tt>~/.config/openbox/rc.xml</tt> file and add the following entry in the <keyboard> section:<br />
<pre><br />
<keybind key="XF86LaunchA"><br />
<action name="Execute"><br />
<startupnotify><br />
<enabled>true</enabled><br />
</startupnotify><br />
<command><br />
xmms<br />
</command><br />
</action><br />
</keybind><br />
</pre><br />
After, right clicking on the desktop and selecting the "Reconfigure" menu option, you should then have xmms pop up when you hit the ThinkVantage key.<br />
<br />
==Example Applications==<br />
===Web Browsers===<br />
====Firefox (<3.0)====<br />
<br />
There are various ways to assign actions to the browser keys. The easiest way is to install [http://mozilla.dorando.at/keyconfig.xpi keyconfig.xpi] from http://mozilla.dorando.at, which adds a menu entry Tools->Keyconfig. Then you can assign any action you want to the F19/F20 keys (you still need to create {{path|~/.Xmodmap}} as explained above).<br />
<br />
<br />
The remaining discussion gives you various more complicated ways to achieve the same thing. <br />
To have firefox make use of the browser keys you need to modify one of its files{{footnote|4}}.<br />
To do this you will first need to extract it from the {{path|browser.jar}} archive. Do...<br />
<br />
Step 1: Edit .Xmodmap and add entries for F19 and F20 as explained above.<br />
<br />
Step 2:<br />
<br />
Note: <firefox-directory> is probably /usr/lib/firefox. Use your version so, if you have 3.0.1 or 3.0.2 use /usr/lib/firefox-3.0.1<br />
<br />
:{{cmdroot|cd <firefox-directory>/chrome}}<br /><br />
:{{cmdroot|unzip browser.jar}}<br />
<br />
The file of interest is {{path|content/browser/browser.xul}}. Edit it {and don't forget to make a backup copy first}...<br />
:{{cmdroot|vi content/browser/browser.xul}}<br />
<br />
Look for the '''<keyset id="mainKeyset">''' section and add the following lines within...<br />
<key id="goBackKb" keycode="VK_F19" command="Browser:Back" /><br />
<key id="goForwardKb" keycode="VK_F20" command="Browser:Forward" /><br />
<br />
The Command you need for Next Tab <br />
<key id="goBackTabKb" keycode="VK_F19" oncommand="gBrowser.mTabContainer.advanceSelectedTab(-1)" /><br />
For the Previous Tab <br />
<key id="goForwardTabKb" keycode="VK_F20" oncommand="gBrowser.mTabContainer.advanceSelectedTab(1)" /><br />
<br />
Now save the file and repackage the {{path|browser.jar}} archive...<br />
:{{cmdroot|zip -rD0 browser.jar content/browser/}}<br />
<br />
That's it.<br />
<br />
Step 3: Restart Firefox.<br />
<br />
{{HINT|Outdated: Another interesting Page on Firefox is http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ It uses different key mappings (F19 resp. F20) but a ready [http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/dqdnavkeys-1.2.xpi .xpi] is provided which is pretty comfortable. However, this xpi file does not install on Firefox 1.5. or later.}}<br />
<br />
{{HINT| You can also use the [http://extensionroom.mozdev.org/more-info/keyconfig keyconfig] extension to configure custom keys. This extension works with Firefox 1.5 and also with Firefox 2.0. The Command you need for Next Tab is gBrowser.mTabContainer.advanceSelectedTab(1,true); For Previous Tab its gBrowser.mTabContainer.advanceSelectedTab(-1,true); You can alternatively install the [http://www.pqrs.org/~tekezo/firefox/extensions/functions_for_keyconfig/index.html functions for keyconfig] and set the variable f4kc_NextTab to F20 and f4kc_PrevTab to F19.}}.<br />
<br />
====Firefox 3.0====<br />
Thankfully the people at Mozilla decided to include the expected functionality for the XF86Back and XF86Forward keysyms in the new release so all you need to do is<br />
<br><code># printf 'keycode 234 = XF86Back\nkeycode 233 = XF86Forward' >> /etc/X11/Xmodmap</code><br><br />
And to make this take effect immediately (i.e., without having to log out and log in again), as a regular user run:<br />
<br>{{cmduser|Xmodmap /etc/X11/Xmodmap}}<br />
<br />
For Hardy Heron, the xmodmap command is all lowercase. Also, the /etc/X11/Xmodmap file is not being read on boot. I've added the command to my .bashrc to have it called on startup.<br />
<br />
====Konqueror====<br />
KDE allows you set key mappings for KDE applications (Go to KMenu > System > Control Center > Regional & Accessibility > Keyboard Shortcuts). By default (at least in KDE 3.5), XF86Back and XF86Forward are set as alternatives to Alt-Left and Alt-Right, and are mapped to KDE Back and Forward navigation actions. <br />
<br />
If you use Konqueror as your only browser, you only need to set up {{path|~/.Xmodmap}} as described [[#xmodmap configuration|above]] to assign ThinkPad back/forward keys to the symbols XF86Back/XF86Forward. This also make these keys work for other KDE applications such as Quanta Plus, KPackage and so on (not all KDE applications honor this setting, e.g. KDE help system doesn't).<br />
<br />
If you want to use Firefox, however, the above settings do not work. You will have to map ThinkPad back/forward keys to F19/F20 as described [[#Firefox|above]], and change KDE navigation key settings to use F19/F20 instead of the default.<br />
<br />
====Opera====<br />
However this isn't a simple configration file, you can set your browser manually.<br /><br />
Go to <i>Tool > Settings > Mouse and keyboard > Keyboard settings > Edit > Browser Window</i>. There add F19 - Back and F20 - Forward. Now you can surf using your TP keys ;-)<br />
<br />
====Epiphany====<br />
By default, the back/forward keys, when bound to XF86Back/XF86Forward, successfully navigate through the history.<br />
<br />
To get them switch through your tabs, you could use the extension from [http://crashman.homelinux.org/~andre/public/epiphany%20extensions/thinkpad%20browserkeys/ here]<br />
You just need to edit your Xmodmap like described for Firefox < 3.0 (bind the keys on F19 and F20)<br />
<br />
====W3M (under Emacs)====<br />
I'm not sure that I want to use the back and forward keys all the time in Emacs, but while browsing the web it is useful to have them.<br />
<br />
On my X61s running Fedora 13, I've found that by adding the following lines to my .emacs, I'm able to do just that:<br />
<br />
<code>(eval-after-load "w3m"<br>'(progn<br>(define-key w3m-mode-map [XF86Back] 'w3m-view-previous-page)<br> (define-key w3m-mode-map [XF86Forward] 'w3m-view-next-page)))</code><br />
<br />
===Open an application===<br />
<br />
To configure the ThinkVantage button to open a terminal window in Gnome:<br />
<br />
Step 1:<br />
Use xev to find the keycode generated by the button on your machine. In my case is is 159.<br />
<br />
Step 2:<br />
Create an entry in .Xmodmap like so<br />
<br />
keycode 159 = XF86LaunchA<br />
<br />
replacing 159 by the keycode found in step 1. Load the map using<br />
<br />
:{{cmd|xmodmap ~/.Xmodmap}}<br />
<br />
Step 3:<br />
Configure the required function (e.g. open terminal window) in System->Preferences->Keyboard shortcuts<br />
<br />
===Window Managers===<br />
====fvwm====<br />
To get the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fvwmrc}}:<br />
Key XF86Back A A Scroll -100000 0<br />
Key XF86Forward A A Scroll +100000 0<br />
If you use multiple virtual desktops, you could instead use the keys to flip between them by using GotoDesk.<br />
<br />
====fluxbox====<br />
To get the keys to cycle through pages in the virtual desktop, add this to your {{path|~/.fluxbox/keys}}:<br />
None F19 :PrevWorkspace<br />
None F20 :NextWorkspace<br />
<br />
====pekwm configuration====<br />
You can make the two browser keys switch workspaces in pekwm, by adding the following two lines to the {{path|~/.pekwm/keys}} file:<br />
KeyPress = "Mod1 XF86Back" { Actions = "GoToWorkspace prev" }<br />
KeyPress = "Mod1 XF86Forward" { Actions = "GoToWorkspace next" }<br />
<br />
====pwm====<br />
Another example how to use these two keys to switch between pwm tabs. These two lines should be added to {{path|~/.pwm/keys-default.conf}} or {{path|/etc/pwm/keys-default.conf}}:<br />
kbind "Back", "switch_rot", -1<br />
kbind "Forward", "switch_rot", 1<br />
<br />
====IceWM====<br />
To make IceWM cycle workspaces using the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys, change these two options in {{path|~/.icewm/preferences}} (Provided you assigned keysyms F19 and F20 with xmodmap):<br />
# "Previous workspace" shortcut<br />
KeySysWorkspacePrev="F19"<br />
# "Next workspace" shortcut<br />
KeySysWorkspaceNext="F20"<br />
<br />
==== Gnome/metacity ====<br />
<br />
On {{Debian}} Lenny, using Gnome 2.22.2, once the acpid and acpi-support packages are installed, most Fn keys do the right thing out of the box.<br />
<br />
For more advanced configuration, follow the [https://wiki.ubuntu.com/Keybindings Ubuntu guide].<br />
<br />
===Other Uses===<br />
====Console tools configuraton====<br />
To make the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys useful in console, add this to your keymap ({{path|/etc/console/boottime.kmap.gz}} in {{Debian}}):<br />
keycode 158 = Decr_Console<br />
keycode 159 = Incr_Console<br />
<br />
Alternatively you can load this script (perhaps on system startup) to enable Backward/Forward button console (VT) switch:<br />
<br />
#!/bin/sh<br />
echo keycode 158 = Decr_Console | loadkeys<br />
echo keycode 159 = Incr_Console | loadkeys<br />
<br />
It should work with any distro.<br />
<br />
====Cycling through tabs====<br />
In Gnome and Xfce4, Ctrl-PageUp/Ctrl-PageDown move to the previous/following open tab in all applications that have tabbed user interfaces (terminal emulator, web browser, ...). To make use of the {{ibmkey|Forward|#494949}} and {{ibmkey|Backward|#494949}} keys for this task, there're two possibilities.<br />
<br />
For both ways, you should map the keycodes 233 and 234 to XF86Back and XF86Forward as described in [[#xmodmap_configuration|xmodmap configuration]].<br />
<br />
=====Using xautomation=====<br />
xautomation can be found [http://hoopajoo.net/projects/xautomation.html here].<br />
<br />
Create two files with permissions 755:<br />
<br />
{{path|/usr/local/bin/tp_back}}:<br />
<bash><br />
#!/bin/bash<br />
/usr/bin/xte 'keydown Control_L' 'keydown Page_Up' 'keyup Page_Up' 'keyup Control_L'<br />
</bash><br />
<br />
{{path|/usr/local/bin/tp_forward}}:<br />
<bash><br />
#!/bin/bash<br />
/usr/bin/xte 'keydown Control_L' 'keydown Page_Down' 'keyup Page_Down' 'keyup Control_L'<br />
</bash><br />
<br />
Use your desktop's keyboard shortcut editor to assign XF86Back as a shortcut for tp_back and XF86Forward as a shortcut for tp_forward.<br />
<br />
This should work in all distros and with all window managers (you might have to use other key combinations than Ctrl-PageUp and Ctrl-PageDown).<br />
<br />
=====Redirecting XF86Back/XF86Forward=====<br />
Create {{path|/etc/X11/xkb/compat/thinkpad}}:<br />
<pre><br />
// $XFree86$<br />
// XFree86 special keysyms<br />
default partial xkb_compatibility "basic" {<br />
interpret.repeat= True;<br />
<br />
interpret XF86Back {<br />
action = Redirect(Key=<PGUP>, modifiers=Control);<br />
};<br />
interpret XF86Forward {<br />
action = Redirect(Key=<PGDN>, modifiers=Control);<br />
};<br />
};<br />
</pre><br />
<br />
Edit {{path|/etc/X11/xkb/compat/complete}} and add <tt>'''augment "thinkpad"'''</tt> so that it looks similar to the following:<br />
<pre><br />
// $XKeyboardConfig: xkbdesc/compat/complete,v 1.3 2005/10/17 00:42:11 svu Exp $<br />
// $Xorg: complete,v 1.3 2000/08/17 19:54:34 cpqbld Exp $<br />
default xkb_compatibility "complete" {<br />
include "basic"<br />
augment "iso9995"<br />
augment "mousekeys"<br />
augment "accessx(full)"<br />
augment "misc"<br />
augment "xfree86"<br />
augment "level5"<br />
augment "thinkpad"<br />
};<br />
</pre><br />
<br />
==External Sources==<br />
*[http://www-307.ibm.com/pc/support/site.wss/document.do?lndocid=MIGR-51537 IBMs page on configuring the ThinkPad buttons (ThinkPad, Access IBM, Mail, Search, and Home buttons) under Linux]<br />
*[http://dqd.com/~mayoff/notes/thinkpad/dqdnavkeys/ Rob Mayoffs page on using IBM Keyboard Navigation Keys in Linux Mozilla and Firefox]<br />
*[http://snarfed.org/space/thinkpad+keys+in+firefox Ryan Barretts blog article about using the browser keys in Firefox]<br />
*[http://chaotika.org/~bluesceada/?page=soft&sub=thinkpad#acpibutn DennisG's help to get the ibm-acpi buttons do useful things] on a {{Z61e}} and possibly {{Z61m}}, {{Z61t}} and {{Z61p}}<br />
*[https://help.ubuntu.com/community/KeyboardShortcuts/#Replacing%20keys%20with%20other%20keys using xbindkeys and xmacro to override key bindings]<br />
{{footnotes|<br />
#Note that the associated functionality for Fn-F* key combinations is not consistent amongst all ThinkPads. We are maintaining [[Default meanings of special keys|a table of associated meanings]].<br />
#if there are more than one tool listed, one is sufficient<br />
#'full' means you can completely reassign any action to be triggered by the key, 'additional actions' means you can trigger actions in addition to the standard function of the key, which can not be changed.<br />
#Thanks go to Ryan Barrett for writing the [http://snarfed.org/space/thinkpad+keys+in+firefox little howto] on [http://snarfed.org/space/start his blog].<br />
}}<br />
<br />
== Weblinks ==<br />
* http://www.freedesktop.org/wiki/Software/XKeyboardConfig</div>Jespergollhttps://www.thinkwiki.org/w/index.php?title=Talk:Thinkpad-acpi&diff=54582Talk:Thinkpad-acpi2013-05-09T14:28:40Z<p>Jespergoll: </p>
<hr />
<div>== Problem with ACPI key event codes in OpenSuse 12.3 ==<br />
<br />
<br />
The below information was relevant on my Thinkpad Z60m running:<br />
Linux 3.7.10-1.1-desktop<br />
OpenSuse 12.3<br />
KDE 4.10.00 "release 1"<br />
<br />
I am currently running:<br />
Linux 3.7.10-1.4-desktop<br />
OpenSuse 12.3<br />
KDE 4.10.2 "release 1"<br />
and everything said below is still valid.<br />
<br />
<br />
--[[User:Jespergoll|Jespergoll]] ([[User talk:Jespergoll|talk]]) 16:20, 9 May 2013 (CEST)<br />
<br />
<br />
----<br />
<br />
<br />
I upgraded my Thinkpad Z60m to OpenSuse 12.3 shortly after its release on March 13th 2013 - and soon found that my ACPI key handling script ({{path|/usr/lib/acpid/thinkpad_handler}}) was broken.<br />
<br />
Specifically, they key events reported by the ACPI driver were different from what they had been before the upgrade - and so the following information (in {{path|../Documentation/laptops/thinkpad-acpi.txt}}) '''was no longer true on my system''':<br />
<br />
The driver will report HKEY events in the following format:<br />
<br />
ibm/hotkey HKEY 00000080 0000xxxx<br />
<br />
Now, instead, the same HKEY events are generally reported in the following format:<br />
<br />
button/xxxxx YYY 00000080 00000000 K<br />
<br />
- where "xxxxx" is a lowercase name for either the key or the key function, and YYY is a shorter, capitalized version of the same. For example, Fn-F12 ("suspend to disk") is now being reported as:<br />
<br />
button/suspend SUSP 00000080 00000000 K<br />
<br />
I have found one exception to this general rule: Fn-F7 (the video switch button) is now being reported as:<br />
<br />
video/switchmode VMOD 00000080 00000000 K<br />
<br />
<br />
So I had to rewrite my key handler script ({{path|/usr/lib/acpid/thinkpad_handler}}), and even the event mask (found in {{path|/etc/acpi/events/thinkpad}}). My general key event mask now looks like this:<br />
<br />
event=button/.*<br />
action=/usr/lib/acpid/thinkpad_handler "%e"<br />
<br />
To get the video switch script back in shape I created an additional event mask ({{path|/etc/acpi/events/video}}) with the following content:<br />
<br />
event=video/switchmode<br />
action=/usr/lib/acpid/video_handler "%e"<br />
<br />
and moved the video switching routines to a new script: {{path|/usr/lib/acpid/video_handler}}.<br />
<br />
<br />
Here is a list of the key events I have explored, and the event reports they now produce:<br />
<br />
{{key|Fn}}{{key|F1}} button/fnf1 FNF1 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F2}} button/battery BAT 00000080 00000000 K {{footnote|1}}<br />
<br />
{{key|Fn}}{{key|F3}} button/screenlock SCRNLCK 00000080 00000000 K {{footnote|1}}<br />
<br />
{{key|Fn}}{{key|F4}} button/sleep SBTN 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F5}} button/wlan WLAN 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F6}} button/fnf6 FNF6 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F7}} video/switchmode VMOD 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F8}} button/zoom ZOOM 00000080 00000000 K {{footnote|2}}<br />
<br />
{{key|Fn}}{{key|F9}} button/f24 F24 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F10}} (not reported)<br />
<br />
{{key|Fn}}{{key|F11}} button/fnf11 FF11 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F12}} button/suspend SUSP 00000080 00000000 K<br />
<br />
{{ibmkey|ThinkVantage|#495988}} button/prog1 PROG1 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|Space}} button/zoom ZOOM 00000080 00000000 K {{footnote|2}}<br />
<br />
{{footnotes|<br />
#Fn-F2 and Fn-F3 seem to have become mixed up in the driver. On my machine at least, Fn-F2 is "lock" and Fn-F3 is "battery".<br />
#Please note that Fn-F8 and Fn-Space now produce identical event reports - so there is no way to distinguish one from the other.<br />
}}</div>Jespergollhttps://www.thinkwiki.org/w/index.php?title=Talk:Thinkpad-acpi&diff=54581Talk:Thinkpad-acpi2013-05-09T14:20:01Z<p>Jespergoll: /* Problem with ACPI key event codes in OpenSuse 12.3 */ new section</p>
<hr />
<div>== Problem with ACPI key event codes in OpenSuse 12.3 ==<br />
<br />
<br />
The below information was relevant on my Thinkpad Z60m running:<br />
Linux 3.7.10-1.1-desktop<br />
OpenSuse 12.3<br />
KDE 4.10.00 "release 1"<br />
<br />
I am currently running:<br />
Linux 3.7.10-1.4-desktop<br />
OpenSuse 12.3<br />
KDE 4.10.2 "release 1"<br />
and everything said below is still valid.<br />
<br />
<br />
--[[User:Jespergoll|Jespergoll]] ([[User talk:Jespergoll|talk]]) 16:20, 9 May 2013 (CEST)<br />
<br />
<br />
----<br />
<br />
<br />
I upgraded my Thinkpad Z60m to OpenSuse 12.3 shortly after its release on March 13th 2013 - and soon found that my ACPI key handling script ({{path|/usr/lib/acpid/thinkpad_handler}}) was broken.<br />
<br />
Specifically, they key events reported by the ACPI driver were different from what they had been before the upgrade - and so the following information (in {{path|../Documentation/laptops/thinkpad-acpi.txt}}) '''was no longer true on my system''':<br />
<br />
The driver will report HKEY events in the following format:<br />
<br />
ibm/hotkey HKEY 00000080 0000xxxx<br />
<br />
Now, instead, the same HKEY events are generally reported in the following format:<br />
<br />
button/xxxxx YYY 00000080 00000000 K<br />
<br />
- where "xxxxx" is a lowercase name for either the key or the key function, and YYY is a shorter, capitalized version of the same. For example, Fn-F12 ("suspend to disk") is now being reported as:<br />
<br />
button/suspend SUSP 00000080 00000000 K<br />
<br />
I have found one exception to this general rule: Fn-F7 (the video switch button) is now being reported as:<br />
<br />
video/switchmode VMOD 00000080 00000000 K<br />
<br />
<br />
So I had to rewrite my key handler script ({{path|/usr/lib/acpid/thinkpad_handler}}), and even the event mask (found in {{path|/etc/acpi/events/thinkpad}}). My general key event mask now looks like this:<br />
<br />
event=button/.*<br />
action=/usr/lib/acpid/thinkpad_handler "%e"<br />
<br />
To get the video switch script back in shape I created an additional event mask ({{path|/etc/acpi/events/video}}) with the following content:<br />
<br />
event=video/switchmode<br />
action=/usr/lib/acpid/video_handler "%e"<br />
<br />
and moved the video switching routines to a new script: {{path|/usr/lib/acpid/video_handler}}.<br />
<br />
<br />
Here is a list of the key events I have explored, and the event reports they now produce:<br />
<br />
{{key|Fn}}{{key|F1}} button/fnf1 FNF1 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F2}} button/battery BAT 00000080 00000000 K {{footnote|1}}<br />
<br />
{{key|Fn}}{{key|F3}} button/screenlock SCRNLCK 00000080 00000000 K {{footnote|1}}<br />
<br />
{{key|Fn}}{{key|F4}} button/sleep SBTN 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F5}} button/wlan WLAN 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F6}} button/fnf6 FNF6 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F7}} video/switchmode VMOD 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F8}} button/zoom ZOOM 00000080 00000000 K {{footnote|2}}<br />
<br />
{{key|Fn}}{{key|F9}} button/f24 F24 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F10}} (not reported)<br />
<br />
{{key|Fn}}{{key|F11}} button/fnf11 FF11 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|F12}} button/suspend SUSP 00000080 00000000 K<br />
<br />
{{ibmkey|ThinkVantage|#495988}} button/prog1 PROG1 00000080 00000000 K<br />
<br />
{{key|Fn}}{{key|Space}} button/zoom ZOOM 00000080 00000000 K {{footnote|2}}<br />
<br />
{{footnotes|<br />
#Fn-F2 and Fn-F3 seem to have become mixed up in the driver. On my machine, at least, Fn-F2 is "lock" and Fn-F3 is "battery".<br />
#Please note that Fn-F8 and Fn-Space now produce identical event reports - so there is no way to distinguish one from the other.<br />
}}</div>Jespergoll