Why does xterm retain keyboard layout even after change?

2

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:

arxanas

Posted 2012-10-24T11:18:34.640

Reputation: 679

Answers

2

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

Orwellophile

Posted 2012-10-24T11:18:34.640

Reputation: 451

Which environment variable is it? env doesn't seem to produce anything relevant. – arxanas – 2012-10-28T22:44:41.050

Who said anything about environment variables? – Orwellophile – 2013-01-22T02:44:57.327

I assumed that's what you meant by "exports your current keyboard settings in the environment." – arxanas – 2013-01-22T03:03:43.883

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 – 2013-01-26T08:38:48.023