3

I have a french and a US keyboard on my computer. I'm using awesome wm and have set everything so that it is easy for me to switch between keyboard layout. But I still have to do it myself.

Theoretically, it should be possible for the computer to understand from which keyboard the input event comes and use the layout associated with the keyboard. I have looked it up but found no good answer. Is it possible to do so ?

I was thinking that I could write a short code analyzing keyboard event and do the switch, but :

  • it would run in parallel with the event handler so there could be concurrency problem (something like this);
  • it looks like a dirty way of doing it and I prefer a clean solution.

Thanks for your help

4

You could do this with by configuring your keyboards separately. For example I use US English layout on my laptop keyboard and have a Sun Type 6 USB keyboard with german layout and I have the following in my /etc/X11/xorg.conf.d/10-evdev.conf:

# Default configuration for all keyboards not handled explicitly
Section "InputClass"
     Identifier "evdev keyboard catchall"
     MatchIsKeyboard "on"
     MatchDevicePath "/dev/input/event*"
     Driver "evdev"

     Option "XkbRules"   "evdev"
     Option "XkbModel"   "pc105"
     Option "XkbLayout"  "us(altgr-intl),de,ru"
     Option "XkbOptions" "lv3:menu_switch,caps:hyper,compose:ralt,grp:rctrl_rshift_toggle,terminate:ctrl_alt_bksp"
EndSection

# Match the external keyboard by USB ID
Section "InputClass"
    Identifier "Sun Type 6"
    MatchIsKeyboard "on"
    MatchUSBID "0430:0005"

    Driver "evdev"
    Option "XkbRules"   "evdev"
    Option "XkbModel"   "sun(type6)"
    Option "XkbLayout"  "de"
    Option "XkbOptions" "caps:hyper,compose:menu,terminalte:ctrl_alt_bksp"
EndSection
| improve this answer | |
  • I've created the file /etc/X11/xorg.conf.d/10-evdev.conf but it doesn't work. I had to create the folder xorg.conf.d and I used MatchUSBID for both keyboards. Identifier can be any string, right ? Did I do something wrong ? – billx Apr 16 '14 at 9:47
  • You should have a look into /var/log/Xorg.0.log to see whether X.org applied the appropriate configuration for your keyboards (look out for XINPUT and the lines around). – Andreas Wiese Apr 16 '14 at 10:09
  • Neat ! Now it's working if I plug the second keyboard after awesome is started, but not working if the keyboard is plugged before booting... Something must be setting the keyboard layout. Any idea of what it could be ? Thanks anyway it solved my problem. – billx Apr 16 '14 at 11:37
  • Splendid! My best guess would be your login manager messing with your layout (since LightDM, GDM & Co. pull up half a Gnome session and use the corresponding config stuff it's a rather good guess, I guess). If you're using awesome anyway, you could try SLiM (the Simple Login Manager). I've made really good experience with it. – Andreas Wiese Apr 16 '14 at 11:58
  • Perfect, everything works perfectly know. I have installed slim. Thank you again ! – billx Apr 16 '14 at 12:39

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.