I finally got the fn key working! I had to compile my own kernel module to do so. I think I coulda solved it in an easier way, but here's what I did:
I found this bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/942184
The very first patch posted on that page had my solution: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/942184/+attachment/2788714/+files/alu2011.patch
Then I proceeded to patch and modify my modules following the article and first comment on
http://www.codewhirl.com/2012/04/how-to-compile-a-single-module-in-ubuntu-linux/
I didn't apply the entire patch, only the lines referring to USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI
with ID 0x0255, since this ID was missing in the kernel source I got. I tried this because I noticed the number 0255 in the syslog earlier: generic-bluetooth 0005:05AC:0255.0006: input,hi...
I don't really fully understand how I did it, but it works!
Here's some Xev output, pressing the left arrow key, first with, and then without fn key:
KeyPress event, serial 34, synthetic NO, window 0x3000001,
root 0x15d, subw 0x3000002, time 1502136, (40,28), root:(1235,427),
state 0x0, keycode 110 (keysym 0xff50, Home), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 34, synthetic NO, window 0x3000001,
root 0x15d, subw 0x3000002, time 1502635, (40,28), root:(1235,427),
state 0x0, keycode 110 (keysym 0xff50, Home), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 34, synthetic NO, window 0x3000001,
root 0x15d, subw 0x3000002, time 1504023, (40,28), root:(1235,427),
state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 34, synthetic NO, window 0x3000001,
root 0x15d, subw 0x3000002, time 1504235, (40,28), root:(1235,427),
state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
The Fn key is not registered as a separate key I can have fun xmodmapping with, but this is sufficient for my goals, turning an apple keyboard into a happy-hacking-like by remapping a few keys.
It appears this is all a known bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/911064
It seems that logitech provides a special driver on various OS's other than Linux that does exactly this swap by sending an undocumented magic command to the keyboard.
Some people have monitored the communication to find the codes sent to some other similar logitech keyboards such as the
760
and the
810. You might try one of those.
Failing that, you can use xmodmap
to swap the key assignments. We see that your keyboard sends 2 different keycodes depending on whether Fn is pressed or not. Use xmodmap -pke
to list all the key mappings in a file, then keep just the ones referring to the wanted keycodes. For example you would have
keycode 67 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1
keycode 180 = XF86HomePage NoSymbol XF86HomePage
and so on. Simply invert the numbers:
keycode 180 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1
keycode 67 = XF86HomePage NoSymbol XF86HomePage
Then pass this filename as argument to xmodmap
to have it update the mapping.
Best Answer
You need to add
0
or2
into/sys/module/hid_apple/parameters/fnmode
.i.e.:
There seems to be some confusion regarding what the difference between the two values might be. Quoting the Ubuntu documentation:
Note that this also works for me on Fedora.
As several people have commented, this change is temporary. You can stick it in your login shell's RC file or into cron so that you don't have to worry about it.
You can also change your driver settings to make this change permanent, like so:
credits to https://askubuntu.com/a/7553