3

I use three different layouts and looking code to change layout programmaticaly from .bashrc function.

nopcorn
  • 9,559
Yurij73
  • 1,992

3 Answers3

1

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.

Emanuel Berg
  • 6,903
  • 8
  • 44
  • 65
1

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.

don_crissti
  • 82,805
0

It may look hacky but it works like a charm:

setxkbmap -layout ru && setxkbmap -layout ru,us
setxkbmap -layout us && setxkbmap -layout us,ru

To force switch:

setxkbmap -layout ru && setxkbmap -layout us && setxkbmap -layout us,ru

You can program your loop if you need.