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

I use Dvorak as my primary keyboard layout, but I like to play nethack, so I change to qwerty and open xterm:

alias nhterm="nohup >/dev/null xterm -fa \"Andale Mono\" -fs 20 -fullscreen -fg white -bg black &"

However, once I change by keyboard layout back (while xterm is still open), I find that xterm keeps typing in qwerty, even though the rest of the OS uses Dvorak again. Why and how does this happen?

Here's the thing I use to change my keyboard layout, if it matters:

share|improve this question
up vote 2 down vote accepted

Because when you launch xterm, it grabs your current keyboard settings, and reads raw keys from the keyboard - rather than asking the operating system for textual input.

Unfortunately I can't give you an absolute answer, because no matter what my input is set to, my xterm ends up using a U.K. keymap (not good for my U.S. keyboard).

That, I have partially diagnosed via setxkbmap

xkb_keymap {
    xkb_keycodes  { include "empty+aliases(qwerty)" };
    xkb_types     { include "complete"      };
    xkb_compat    { include "complete"      };
    xkb_symbols   { include "empty(basic)"  };
    xkb_geometry  { include "pc(pc104)"     };
};

Not sure where it gets it's defaults from, but I gather than when it's working right, you can just type something like:

setxkbmap dvorak

see: http://zuttobenkyou.wordpress.com/tag/setxkbmap/

It may also help to install some extras, if you can:

sudo port install xkeyboard-config xkbcomp setxkbmap

By the way, if you did want to use different keymaps in different apps,

Languages & Text

share|improve this answer
    
Which environment variable is it? env doesn't seem to produce anything relevant. – arxanas Oct 28 '12 at 22:44
    
Who said anything about environment variables? – Orwellophile Jan 22 '13 at 2:44
    
I assumed that's what you meant by "exports your current keyboard settings in the environment." – arxanas Jan 22 '13 at 3:03
    
Bad choice of words on my part, I'll edit. Still haven't fixed my own problem (XQuartz is using UK layout on my US keyboard). – Orwellophile Jan 26 '13 at 8:38

You must log in to answer this question.

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