Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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 was marked as an exact duplicate of an existing 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

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

Not the answer you're looking for? Browse other questions tagged .