Situation
I have a Microsoft Sculpt Mobile Keyboard, which is connected via Bluetooth. On my laptop a xUbuntu 16.04 is running.
The F1 to F12 keys of the Sculpt Mobile Keyboard work as function keys Play/Pause, Mute, ... . To use the F1 to F12 keys as intended, one needs the press the Fn keys, which is on the right. This is quite uncomfortable if you want to press ALT+F4 ... . I would like to switch permanently to the Fx keys (or lock the Fn key). Additionally, I would like to switch PageUp and PageDown keys against Home and End.
Windows Solution
Use AutoHotKey as described in
- Microsoft Sculpt Mobile Keyboard reverse Fn keys and
- "Microsoft Sculpt Mobile Keyboard Remap" for AutoHotKey at GitHub.
Not-working Solution
Answer applies to another keyboard
Linux Solution for other Keyboards (not working)
It should be possible to change or switch keys with the command line tools xkbcomp or setxkbmap as described here:
- Superuser: How to remap keys under Linux for a specific keyboard only
- AskUbuntu: What's the opposite of setxkbmap -option ctrl:nocaps?
- Stackoverflow: Create a custom setxkbmap option
- xkbcomp keymapping overview at GitHub
- AskUbuntu: Change keyboard mapping ONLY for Bluetooth Keyboard
- Unix & Linux: Use setxkbmap to swap the Left Shift and Left Control
Based on these questions and answers, I used xev to find the key names (XKB identifiers) of the keys in question. I wanted to create the following mapping:
# F1 to F5 (F5 probably does not work)
I172 -> FK01
MUTE -> FK02
VOL- -> FK03
VOL+ -> FK04
FIND -> FK05
# F11 and F12
FK22 -> FK11
FK23 -> FK12
# switch Page Up and Page Down with Home and End
PGUP -> HOME
HOME -> PGUP
PGDN -> END
END -> PGDN
Thus, I created the appropriate code:
xkb_symbols "remote" {
key <I172> {
type= "CTRL+ALT",
symbols[Group1]= [ F1, F1, F1, F1, XF86Switch_VT_1 ]
};
key <MUTE> {
type= "CTRL+ALT",
symbols[Group1]= [ F2, F2, F2, F2, XF86Switch_VT_2 ]
};
key <VOL-> {
type= "CTRL+ALT",
symbols[Group1]= [ F3, F3, F3, F3, XF86Switch_VT_3 ]
};
key <VOL+> {
type= "CTRL+ALT",
symbols[Group1]= [ F4, F4, F4, F4, XF86Switch_VT_4 ]
};
key <FIND> {
type= "CTRL+ALT",
symbols[Group1]= [ F5, F5, F5, F5, XF86Switch_VT_5 ]
};
key <FK22> {
type= "CTRL+ALT",
symbols[Group1]= [ F11, F11, F11, F11, XF86Switch_VT_11 ]
};
key <FK23> {
type= "CTRL+ALT",
symbols[Group1]= [ F12, F12, F12, F12, XF86Switch_VT_12 ]
};
key <PGDN> { [ End ] };
key <END> { [ Next ] };
key <PGUP> { [ Home ] };
key <HOME> { [ Prior ] };
};
And added it to the existing key map definition with xkbcomp and added +custom(remote) to the xkb_symbols variable of the key mapping of the device respective device. It did not work.
I think that they maybe do not work because the keyboard is recognized as pointer and not as keyboard. The xinput list output says:
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Mouse id=11 [slave pointer (2)]
⎜ ↳ AlpsPS/2 ALPS DualPoint TouchPad id=14 [slave pointer (2)]
⎜ ↳ AlpsPS/2 ALPS DualPoint Stick id=15 [slave pointer (2)]
⎜ ↳ Microsoft Sculpt Mobile Keyboard id=17 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Video Bus id=8 [slave keyboard (3)]
↳ Power Button id=9 [slave keyboard (3)]
↳ Sleep Button id=10 [slave keyboard (3)]
↳ Laptop_Integrated_Webcam_E4HD id=12 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=13 [slave keyboard (3)]
↳ Dell WMI hotkeys id=16 [slave keyboard (3)]
Alternative Solutions (not tried)
I read about some mice that were recognized as keyboard and not as pointer. Modifying the Linux Kernel code + recompiling it was one of the solutions. I don't want to recompile the Kernel just to get my keyboard properly working ... .
Hardware solution (working)
Question
- Is my assumption in "Linux Solution for other Keyboards" wrong?
- If the answer to the first question is no: How do I solve the described issue software-based (switch and replace keys) without recompiling my Kernel?
