Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 three different layouts and looking code to change layout programmaticaly from .bashrc function.

share|improve this question
If you're using X: What about setxkbmap? – Marco Oct 30 '12 at 19:21
.bashrc is definitely not the right file for this. It's run when you start a shell, not when you log in. See Alternative to .bashrc – Gilles Oct 31 '12 at 21:37

For example, to get the US layout (that is, by the way, excellent for programming; see this question).

In X, try setxkbmap -layout us

In the Linux console, add XKBLAYOUT="us" to /etc/default/keyboard; then run setupcon as superuser. Or, use dpkg-reconfigure keyboard-configuration (also as superuser). You could also use a different map in the console than in X by using KMAP; look in /etc/console-setup/.

This may require some fiddling; possibly, you'd like to write aliases and/or functions in your .bashrc for fast access. If you plan on switching back and forth, I've found that a compose key is a better solution. Unless, of course, you're writing in a totally different alphabet.

share|improve this answer

It is indeed strange that X11 doesn't provide a standard tool to switch to a given layout (when you define several with setxkbmap).

But I just found a tool that can do it: xkblayout-state

With it you can get/set the current layout, either by name or by position in your layout stack.

share|improve this answer

Your Answer


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.