Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
    
Thanks for you quick reply. I'll try this. –  billx Apr 16 '14 at 8:39
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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