I want to map Fn-F1 to execution of a command on MacBookPro 11,5. The problem is that currently Fn-F1 is not detected as any key. I don't know how to bind these to (XF86MonBrightnessDown) and (XF86MonBrightnessUp)
I tried Some keys are not detected in my keyboard (multimedia keys?) by either xev or xbindkeys or keytouch: how to detect them? but after installing that, xev still can't detect Fn-F1 and Fn-F2.
I followed https://help.ubuntu.com/community/AppleKeyboard to set Fn-F12 key to work as in normal laptop. This step makes Fn-F1 instead of F1 undetectable.
Add following line to /etc/modeprob.d/hid_apple.conf:
options hid_apple fnmode=2
Run the following command:
sudo update-initramfs -u -k all
I found scan codes for Fn-F1 and Fn-F2
- switch to console with Alt-Ctrl-F1.
- showkey -s
- press and release Fn-F1 and Fn-F2. record scancodes
Result:
Fn-F1 pressed
0xe0 0x4c
Fn-F1 released
0xe0 0xcc
Fn-F2 pressed
0xe0 0x54
Fn-F2 released
0xe0 0xd4
setkeycodes can't bind any scancode to key code
Cannot bind numlock to key_A:
$ setkeycodes 45 30
setkeycodes: failed to set scancode 45 to keycode 30: ioctl KDSETKEYCODE: Invalid argument
Output of xmodmap -pk
232 0x1008ff03 (XF86MonBrightnessDown) 0x0000 (NoSymbol) 0x1008ff03 (XF86MonBrightnessDown)
233 0x1008ff02 (XF86MonBrightnessUp) 0x0000 (NoSymbol) 0x1008ff02 (XF86MonBrightnessUp)
xev can't distinguish Fn-F1 and Fn-F2
[Fn-F2 pressed with mouse out of window]
FocusIn event, serial 48, synthetic NO, window 0x2800001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 48, synthetic NO, window 0x0,
keys: 4294967206 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[Fn-F2 pressed with mouse in window]
FocusIn event, serial 48, synthetic NO, window 0x2800001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 48, synthetic NO, window 0x0,
keys: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[Fn-F1 pressed with mouse in window]
FocusIn event, serial 48, synthetic NO, window 0x2800001,
mode NotifyGrab, detail NotifyPointer
KeymapNotify event, serial 48, synthetic NO, window 0x0,
keys: 4294967206 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
[Fn-F1 pressed with mouse out of window]
FocusIn event, serial 48, synthetic NO, window 0x2800001,
mode NotifyUngrab, detail NotifyAncestor
KeymapNotify event, serial 48, synthetic NO, window 0x0,
keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[Fn-F1 released]
FocusOut event, serial 48, synthetic NO, window 0x2800001,
mode NotifyUngrab, detail NotifyPointer
[F1 key pressed and release]
KeyPress event, serial 48, synthetic NO, window 0x2800001,
root 0x4a6, subw 0x0, time 2628754, (87,17), root:(88,43),
state 0x0, keycode 67 (keysym 0xffbe, F1), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 48, synthetic NO, window 0x2800001,
root 0x4a6, subw 0x0, time 2628906, (87,17), root:(88,43),
state 0x0, keycode 67 (keysym 0xffbe, F1), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False