Page 1 of 1

Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Tue Sep 15, 2009 9:00 am
by CyberDude
I'm using KDE4.3.1 with openSUSE on my x60s and am having trouble getting some of the special keys to work. The ones that don't work are Fn+F2, Fn+F3, Fn+F4, Fn+F7, Fn+F9, Fn+F12. In Systemsettings when trying to enter a key combination to set a shortcut the Fn key is not recognised at all.

However it does work for some of the Fn combinations which I believe are controlled by the bios. E.G Fn+F5 (toggle radios), Fn+F7 (toggle external screen), Fn+ScrLk (toggle Numlock), Fn+PgUp (toggle thinklight), Fn+Home (increase screen brightness), Fn+End (decrease screen brightness).

These did work in Gnome so it seems to be a KDE thing. I'd like to hear if anyone with a x60/s or x61/s has these buttons working in KDE.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Tue Sep 15, 2009 9:01 pm
by GomJabbar
Try acpi_listen in terminal to see if the hotkey presses generate ACPI events. Try running /etc/rc.d/init.d/acpid restart in a terminal as root to reset acpi. Oftentimes this is all that is needed.

For example, when I press Fn+F6, the following happens...

Code: Select all

[dkb@2378-FVU ~]$ acpi_listen
ibm/hotkey HKEY 00000080 00001006
^Z
[1]+  Stopped                 acpi_listen
[dkb@2378-FVU ~]$ 

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Wed Sep 16, 2009 2:59 am
by bodiless
If you see with acpi_listen that you you indeed generate ACPI events, as GomJabbar mentioned, then you need to put in place some scripts and change some config files. From my experience, this will most likely depend on the distribution you use. I personally use debian lenny, but I did some tests with other distros as well. I used Ubuntu, Sidux, Puppy and a few others which I don't remember at the moment, but not opensuse. Only with Ubuntu and a full gnome desktop most keys worked out of the box. But I prefer debian and I don't mind configuring some scripts. You can find many helpfull articles on the thinkwiki page but elsewhere too. Just as an example all I had to do to switch between my x61s and my external monitor is follow the advice found in the fn-f7 thinkwiki section or on this site.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Wed Sep 16, 2009 3:13 am
by CyberDude
Thanks guys. I'll try as suggested.

@bodiless, when I briefly tried Gnome in openSUSE almost all the Fn keys worked out of the box too which seems to agree with what you experienced with Ubuntu and the Gnome desktop. Since it works in Gnome I assume it's more of a KDE or QT problem.

I'll see if the Fn key presses generate anything with acpi_listen and report back.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Thu Sep 17, 2009 1:05 pm
by CyberDude
OK, an update. I ran the acpi_listen in the terminal and all the Fn+F? key presses registered so the keys are being recognised in the terminal at least.

Now I need to figure out how to create or add these keycodes to scripts :?

I've read through the thinkwiki articles a couple of times (in particular THIS one) but I'm not a programmer and am very new to Linux so it's difficult to follow.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Thu Sep 17, 2009 3:22 pm
by GomJabbar
Look for /usr/share/hal/fdi/information/10freedesktop/30-keymap-module-thinkpad-acpi.fdi
If it is there, try running /etc/rc.d/init.d/acpid restart in a terminal as root to reset acpi. Then try your hotkeys.

Try running cat /proc/acpi/ibm/hotkey in terminal.

Code: Select all

[dkb@2378-FVU ~]$ cat /proc/acpi/ibm/hotkey
status:		enabled
mask:		0x008c7fff
commands:	enable, disable, reset, <mask>
[dkb@2378-FVU ~]$ 
You can run xev in terminal and check your keys.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 18, 2009 2:40 am
by bodiless
Maybe it would be easier if you tell us which one you want to configure. For example, following the links in my previous post configuring fn-f7 is as simple as:

1. Modify a bit your /etc/X11/xorg file (you need to add a "Virtual value1 value2" line and the values depent on the screens you have)
2. Create /usr/local/sbin/toggle-display.sh (you can find a sample script in the links)
3. Make the script executable and chown as root:your-user-name
4. Edit and point /etc/acpi/events/ibm-videobtn to the script

*In fact do you have the ibm driver installed? Look in /etc/acpi/events/ You should have there some files like ibm-videobtn etc.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 18, 2009 3:29 am
by CyberDude
GomJabbar wrote:Look for /usr/share/hal/fdi/information/10freedesktop/30-keymap-module-thinkpad-acpi.fdi
If it is there, try running /etc/rc.d/init.d/acpid restart in a terminal as root to reset acpi. Then try your hotkeys.
/usr/share/hal/fdi/information/10freedesktop/30-keymap-module-thinkpad-acpi.fdi does exist. I don't have time till this evening when I'll try resetting the acpid and running xev as suggested.
bodiless wrote:Maybe it would be easier if you tell us which one you want to configure. For example, following the links in my previous post configuring fn-f7 is as simple as:

1. Modify a bit your /etc/X11/xorg file (you need to add a "Virtual value1 value2" line and the values depent on the screens you have)
2. Create /usr/local/sbin/toggle-display.sh (you can find a sample script in the links)
3. Make the script executable and chown as root:your-user-name
4. Edit and point /etc/acpi/events/ibm-videobtn to the script

*In fact do you have the ibm driver installed? Look in /etc/acpi/events/ You should have there some files like ibm-videobtn etc.
What is the ibm driver? Where can I look for it? The only things I have in /etc/acpi/events/ is power_button and thinkpad. the contents of thinkpad is

Code: Select all

# forward acpi events to the thinkpad handler (bluetooth etc.)

event=ibm/.*
action=/usr/lib/acpid/thinkpad_handler "%e"
The contents of /usr/lib/acpid/thinkpad_handler is

Code: Select all

#!/bin/bash

HOTKEY=$1
set $HOTKEY
EVENT=$1   # "ibm/hotkey"
ACPI=$2    # "HOTK"
WHAT=$3    # "00000080"
SERIAL=$4  # "0000100c" Fn+F12

# bluetooth
if [ "$WHAT" = "00000080" -a "$SERIAL" = "00001005" ]; then
	ACTION="disable"
	grep -q "disabled" "/proc/acpi/ibm/bluetooth" && ACTION="enable"
	echo $ACTION > "/proc/acpi/ibm/bluetooth"
fi
Apart from the one other power_button script there no other references to other button scripts. This is the part of Linux I'm really having trouble getting my head around. It's like following bread crumbs :D , one script leads to another which leads to another. The same script seems to appear in multiple locations or at lease as symbolic links.

The keys I want to enable are:
Fn+F2 Screen lock
Fn+F3 Battery (which I'll set to the power manager)
Fn+F4 Suspend to ram
Fn+F7 Toggle monitors (you have provided solution n Thinkwiki)
Fn+F8 Touchpad/trackpoint (which I'll set to trackpoint settings)
Fn+F9 Eject from dock
Fn+F12 Supend to disk
Fn+SPACE - Zoom
Fn+Left Arrow - Play previous
Fn+Right Arrow - Play next
Fn+Down Arrow - Play / Pause
Fn+Up Arrow - Stop playback
ThinkVantage button (which I'll set to bring up the SUSE admin settings)

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 18, 2009 5:50 am
by bodiless
OK I see now,

after doing some research I see than with newer kernels >2.6.27 the thinkpad-acpi driver is not used any more. I am running kernel 2.6.26 and I am defenetely using this driver, so this is maybe why I have all the ibm scripts in my /etc/acpi/events/.

In your case you probably need to edit your /usr/lib/acpid/thinkpad_handler file which looks to me as if it doesn't contain very much. From my understanding it should contain entries for all hotkeys. I did some googling and found that some people have posted their thinkpad_handler script which indeed contains entries for various hotkeys. Maybe you could do the same and find and test some of them?

Could some other knowledgable members here confirm that the thinkpad_handler needs to be edited and help out making a basic script?

Sorry for not being able to help more...

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 18, 2009 6:11 am
by CyberDude
Thanks for the help so far. It's been useful in trying to make more sense of this.

I'm running 2.6.27 and also came across the reference to the newer kernels not using thinkpad_acpi. I still have the thinkpad_acpi on my system as I just did a search for it and came up with many folders with that name and also a module called thinkpad_acpi. The module contents is

Code: Select all

#
# IBM/Lenovo ThinkPad ACPI driver options
#
# A detailed description of the parameters for the ThinkPad ACPI driver can be found
# in  /usr/src/linux/Documentation/laptops/thinkpad-acpi.txt which is part of the package
# 'kernel-source'.
#
# If you encounter problems with the hotkey mask please file a bug on
# http://bugzilla.novell.com/
#

options thinkpad_acpi experimental=1 hotkey=enable,0xffffff
I'll google for the handler scripts in the meantime and see what I find.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 18, 2009 12:42 pm
by CyberDude
GomJabbar wrote:If it is there, try running /etc/rc.d/init.d/acpid restart in a terminal as root to reset acpi. Then try your hotkeys.

Try running cat /proc/acpi/ibm/hotkey in terminal.

Code: Select all

[dkb@2378-FVU ~]$ cat /proc/acpi/ibm/hotkey
status:		enabled
mask:		0x008c7fff
commands:	enable, disable, reset, <mask>
[dkb@2378-FVU ~]$ 
You can run xev in terminal and check your keys.
OK, an update.
I restarted acpid but that didn't help.
Running cat /proc/acpi/ibm/hotkey produced this

Code: Select all

status:         enabled
mask:           0x00ffffff
commands:       enable, disable, reset, <mask>
Running xev - interestingly, it didn't recognise all the keys that acpi_listen did but it picked up a few that acpi-Listen didn't recognise, I am not at my laptop now but iirc it was the Fn+up/down/left/right arrows that xev saw but acpi_listen didn't.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 18, 2009 2:17 pm
by GomJabbar
Try running as root: echo 0x008c7fff > /proc/acpi/ibm/hotkey

Check with cat proc/acpi/ibm/hotkey

When done, run as root: /etc/rc.d/init.d/acpid restart

FWIW, when I was using older kernels, I had ibm-acpi installed. This installs scripts to /etc/acpi/events, and /etc/acpi/actions. If ibm-acpi is available for your distro, try installing it. Also rerun /etc/rc.d/init.d/acpid restart whenever you make changes.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Mon Sep 21, 2009 4:27 am
by CyberDude
Changing the mask didn't help, in fact it seemed to disable some of the special keys. I will need to carefully work through some of those wikis and see if I can get it working.

It still puzzles me as why they worked in Gnome. I wouldn't expect the desktop enviroments to actually mess with the acpi demons, thinkpad_acpi keycodes and masks. There is something in KDE which stops it working and I can only think it's in the QT system.

In November openSUSE 11.2 will be released with the 2.6.31 kernel so I think I may just wait for that and see how it works without relying on thinkpad_acpi.

I'll give it one last try by mapping keycodes and scripts and documented in the various wikis and if it doesn't work then I'll just wait for the upgrade.

Thanks for your help.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Mon Sep 21, 2009 9:27 am
by GomJabbar
I am using KDE 4.2 in Mandriva 2009.1 and my hotkeys work on my T42.

One thing to check is run xev and see if those key combos register as X86xxxx keys. Fn by itself will register as keycode 151 (keysym 0x1008ff2b, XF86WakeUp), but this does not seem to be a problem. If you find that your keycombo is being seen as an XF86xxxx key, then you can mask out that key in /home/user/.Xmodmap. You can check if your changes took by running xmodmap -pke from terminal. Here is my .Xmodmap in Fedora 11 Gnome.

Code: Select all

keycode 166 = F19
keycode 167 = F20
keycode 150 =
keycode 213 =
keycode 160 =
In Mandriva, I put the following file xmodmap in /home/dkb/.kde4/Autostart/ to make sure my settings got looded at boot up.

Code: Select all

#!/bin/sh
# Startup script executed whenever kde starts
# Load the keymap for browser forward/back keys
/usr/bin/xmodmap /home/dkb/.Xmodmap
exit 0

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Mon Sep 21, 2009 11:06 am
by CyberDude
OK, I'll give it a try this evening and see what the key combos registers with xev.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Mon Sep 21, 2009 11:11 am
by GomJabbar
I might not have been entirely clear in my previous post. In the .Xmodmap file I posted above, the lines keycode xxx = {blank} prevents the key from being recognized as a XF86xxxx key. I did this in Fedora 11 to get certain hotkeys to work properly. In my case, I did this to cure a double resume problem from Suspend and Hibernate.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Mon Sep 21, 2009 1:02 pm
by CyberDude
OK, I've done a little playing with xev and have the following observations. My Fn key has keycode 227.

I noticed that some of the keys say 'nosymbol' e.g. FnF2, FnF3, FnF4, FnF9, FnF12

Code: Select all

KeyRelease event, serial 34, synthetic NO, window 0x3e00001,
    root 0x7c, subw 0x3e00002, time 633080, (31,41), root:(107,203),
    state 0x0, keycode 146 (keysym 0x0, NoSymbol), same_screen YES, 
    XLookupString gives 0 bytes:                                    
    XFilterEvent returns: False                                     

KeyPress event, serial 34, synthetic NO, window 0x3e00001,
    root 0x7c, subw 0x3e00002, time 634644, (31,41), root:(107,203),
    state 0x0, keycode 241 (keysym 0x0, NoSymbol), same_screen YES, 
    XLookupString gives 0 bytes:                                    
    XmbLookupString gives 0 bytes:                                  
    XFilterEvent returns: False                                     

KeyRelease event, serial 34, synthetic NO, window 0x3e00001,
    root 0x7c, subw 0x3e00002, time 634644, (31,41), root:(107,203),
    state 0x0, keycode 241 (keysym 0x0, NoSymbol), same_screen YES, 
    XLookupString gives 0 bytes:                                    
    XFilterEvent returns: False  
I guess I need to map the above keys to their functions somehow. I'Ll need to do some googling and wiki reading.

Some like FnF7 (screen toggle), FnUP (Stop playback) FnDown (Start/pause playback),etc have the XF86xxxxx

Code: Select all

KeyPress event, serial 34, synthetic NO, window 0x3e00001,
    root 0x7c, subw 0x3e00002, time 565237, (35,43), root:(111,205),
    state 0x0, keycode 214 (keysym 0x1008ff59, XF86Display), same_screen YES,                                                                         
    XLookupString gives 0 bytes:                                           
    XmbLookupString gives 0 bytes:                                         
    XFilterEvent returns: False 
So I assume I can easily modify the XF86xxxx ones with Xmodmap.

FnSPACE doesn't respond at all in Xev but it is recognised by acpi_listen.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Mon Sep 21, 2009 1:31 pm
by GomJabbar
You might have the wrong keyboard selected to get a no symbol result.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Tue Sep 22, 2009 12:39 pm
by CyberDude
GomJabbar wrote:You might have the wrong keyboard selected to get a no symbol result.
Interesting comment. I just looked and my keyboard is set as follows
Image

The other IBM choices are for the old Thinkpads like the 600 series. I assume that the current choice which was chosen by the installer is correct.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Tue Sep 22, 2009 2:24 pm
by GomJabbar
I am not sure which would be the most compatible one to use for your ThinkPad. I just looked at the keyboard Fedora 11 chose for my T42, and it is the Endev-managed keyboard with the USA Layout. You might try that one, or one of the generic keyboard layouts.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Wed Sep 23, 2009 2:46 am
by CyberDude
Endev-managed definitely not the correct one. My keys were all over the place. I'm not convinced it's the keyboard driver other wise this would have showed up in Gnome too not just KDE.

I'm going on vacation for 10 days so will spend some of my free time on the plane re-reading the wikis and working on scripts.

Re: Anyone got Fn keys working in KDE on x60/s or x61/s?

Posted: Fri Sep 25, 2009 12:23 pm
by bodiless
CyberDude wrote:In November openSUSE 11.2 will be released with the 2.6.31 kernel so I think I may just wait for that and see how it works without relying on thinkpad_acpi.
Yeahh I also hope this issue will be fixed soon.

Inspired by this post I installed a 2.6.30 kernel to do some further testing on my x61s as I am not very happy the way it works with the thinkpad-acpi driver. For example, one of my main problems is that it wakes up immediately after suspending to ram if I have the mouse usb receiver in one of the usb ports. If I first remove the receiver and then Fn+F4 then it works ok (see this thread). So, here are my observations after installing the 2.6.30 kernel:

1. First of all, after booting into the new kernel I could not get any acpi_listen events. It returned the following error:

Code: Select all

open acpi failed var run acpid.socket no such file or directory
After upgrading the acpid from 1.0.8 to 1.0.10 from the debian testing branch this issue was fixed.

2. However, running acpi_listen and pressing various Fn+Fx keys didn't produce events always. So something probably is broken. For example Fn+F4 produces

Code: Select all

button/sleep SBTN 00000080 00000000
The weird thing is that it doesn't produce the event every time the keys are pressed. New presses don't produce any event at all. If I wait long enough however and press the keys again, I get a new event, but, again only once. Same happens with most other keys. By searching, I came across this bug which seems related.

So for the moment I returned to the 2.6.26 kernel with the thinkpad-acpi driver and it kinda works ok but with the problems I mentioned above.

PS. By the way, if you want to use the thinkpad-acpi driver and don't have the scripts in place you need to install the acpi-support package (at least for debian).