I have the current setup:

  • One PS2 Keyboard
  • One USB Keyboard

Then I use this:

xinput --create-master SecondKeyboard

xinput --reattach "Keyboard Id" "Master Id"

to separate them.

I thought I could just create a custom layout and voilá, one keyboard for writing and another for shortcuts, then I discovered xkb doesn't allow to create layouts that click multiples keys (as in pressing capslock and it doing ctrl+alt+f4).

So my thought was, have xbindkeys only run on one of the keyboards, since they have different id's. Can I make this happen?

  • 1
    I don't think you can do that, however you could make XKB send a keysym on one keyboard that doesn't exist in the other layout, and make xbindkeys react to that keysym. – Gilles Apr 30 '17 at 22:24
  • @Gilles how would I go about doing that? – hiperbolt May 1 '17 at 11:21

Quick summary of the various levels involved:

Your keyboard generates scan codes. These are mapped by the kernel input layers to keycode events on /dev/input/eventX. The X evdev driver takes these events, and translates them to keysyms. Then XInput extension makes all events from slaves of the Virtual core keyboard available as normal X events, while the other events are only available as XInput events.

So you have the following options:

1) Set up a custom scancode to keycode mapping. These mappings are per device, so this is actually possible, but this is done via an IOCTL, and there seem to be no ready-made tools for it other than the hwdb in udev. You can then use the new keycides in xkb. Both keyboards are kept as core keyboards.

2) Extend xbindkeys to understand XInput events, so you can use it to bind on events from a non-core keyboard. This will need programming, but should be comparatively straightforward. In this case, decouple one keyboard from the core keyboard as you have already done.

  • Hey! Thanks for the help I'm having a bit of a struggle though, since the PS2 isnt showing up in the Virtual Core keyboard @dirkt – hiperbolt May 1 '17 at 13:52

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.