Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Separate keyboard for shortcuts on linux (two keyboards,two layouts)

I have a laptop with a US layout and an external keyboard with a Spanish layout. Is it possible to detect from which keyboard the last keypress came so I can change the layout accordingly? It could be a simple script using setxkbmap that runs after logging in.

edit: Separate keyboard for shortcuts on linux (two keyboards,two layouts) works perfectly.

share|improve this question

migrated from stackoverflow.com Dec 17 '11 at 1:24

This question came from our site for professional and enthusiast programmers.

marked as duplicate by studiohack Dec 20 '11 at 2:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
It certainly seems possible; setxkbmap applies to all currently connected keyboards, and plugging in a new one (e.g. USB) on xorg.conf-less Xorg 7.6 gives me default US layout on the external one. –  jørgensen Dec 16 '11 at 21:35
    
@JoeyAdams I did't know that site existed, sorry, is there a way I can move it myself? –  Diego Gaustein Dec 16 '11 at 21:49
add comment

1 Answer

Each keyboard can already have its own independent layout. Setting it via HAL (on systems that still have it) works, and the keyboard will acquire the assigned layout on plug/start, provided no other program (e.g. GNOME's keyboard settings plugin) overrides it.

share|improve this answer
    
I added some rules to HAL's preferences which seem to be sticking (one keyboard shows input.xkb.layout = 'es' when inspected with hal-device, and the other shows 'en' with variant 'alt-intl'. But the main layout I set when I first installed Debian (en_us) seems to be sticking in the console as well as in X. Any hints? –  Diego Gaustein Dec 17 '11 at 23:56
add comment

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