I'm running archlinux on my thinkpad x1 carbon 5th gen which has some extra keys. These keys currently do nothing and I'd like to remap them.

Firstly, I tried getting their keycodes via xev but they weren't being detected so I found out their keycodes via evtest.

Here are the results:

Event: time 1519668920.038747, type 4 (EV_MSC), code 4 (MSC_SCAN), value 45
Event: time 1519668920.038747, type 1 (EV_KEY), code 364 (KEY_FAVORITES), value 1
Event: time 1519668920.038747, -------------- SYN_REPORT ------------
Event: time 1519668920.038836, type 4 (EV_MSC), code 4 (MSC_SCAN), value 45
Event: time 1519668920.038836, type 1 (EV_KEY), code 364 (KEY_FAVORITES), value 0
Event: time 1519668920.038836, -------------- SYN_REPORT ------------
Event: time 1519668923.198764, type 4 (EV_MSC), code 4 (MSC_SCAN), value 49
Event: time 1519668923.198764, type 1 (EV_KEY), code 374 (KEY_KEYBOARD), value 1
Event: time 1519668923.198764, -------------- SYN_REPORT ------------
Event: time 1519668923.198883, type 4 (EV_MSC), code 4 (MSC_SCAN), value 49
Event: time 1519668923.198883, type 1 (EV_KEY), code 374 (KEY_KEYBOARD), value 0
Event: time 1519668923.198883, -------------- SYN_REPORT ------------

So tried mapping them to regular keys using xmodmap. For ex.

keycode 374 = F13 or

keycode 374 = XF86LaunchB

but was unsuccessful. How do I go about this? I have also tried to set the scan codes to keycodes via setkeycoder 45 255 but to no avail.

  • 3
    X11 protocol uses 1 byte so keycodes over 255 are invalid, and xmodmap and setxkbmap can't help you here. maybe remap them with a udev hwdb override? (xkbcommon under Wayland compositors won't have this issue, though any Xwayland clients probably still will.) – quixotic Feb 26 '18 at 20:40
  • 1
    If it is not a usb keyboard you can use setkeycodes but you must renumber it to a value less than 255-8 i.e. 247 because 8 will get added to it for the X11 server. – meuh Feb 27 '18 at 15:18
  • @quixotic I'm using Xorg, can you advise me something to use with it? – Nav Saini Feb 28 '18 at 11:52
  • @meuh yes it's not a USB keyboard, it's the inbuilt keyboard on my laptop. I tried setting the scancode to 247 using setkeycodes 45 247 and then xmodmap -e 'keycode 255 = XF86AudioMute' to test but no success.. – Nav Saini Feb 28 '18 at 11:54

The only thing that comes to mind is Gianni Ceccarelli's patched xf86-input-evdev which adds a new xorg configuration option called event_key_remap (details on his page).
I can't test it with an actual keyboard - my laptop keyboard doesn't produce keycodes above 255 - but I've successfully used it in the past to remap buttons on remote controls for mythTV setups.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.