8

How can you change the keyboard layout (to QWERTY from QWERTZ) on the fly from a Linux shell?

I found this similar question, but the answer was to edit a config file, which is not so easy when you're using a Live CD.

6 Answers 6

6

setxkbmap

1
  • 1
    I never said I was running X... I am actually, but do you know how to do it from the console?
    – Hugh Allen
    Nov 3, 2009 at 10:17
8

kbdconfig or loadkeys

That's how we used to do it. I don't know if they're still supported; I'll check next time I've got Knoppix running.

1
  • loadkeys works on Arch. Can't use setxdbmap because I don't have X installed.
    – beatgammit
    Dec 8, 2012 at 17:33
1

I'm not aware of any tool that changes keymap on-the-fly, but in at least debian it is possible to edit /etc/default/console-setup with your preferred map, and make the system reflect those changes by issuing /etc/init.d/hal restart.

1

On recent systems, if you have root privileges, you can use the following:

localectl set-keymap en_GB

for the virtual console keyboard, and

localectl set-x11-keymap en_GB

for the X11 layout.

0

Another option:

Go in the menu and add your layout to keyboard:

System->Preferences->Keyboard, where choose Layouts tab and add your language (the default is the one chosen at installation time). Then you can press the Layout Options... button, and look in Key(s) to change layout for the hot keys that changes the Keyboard layout. For me it is Shift+Caps Lock.

Hope to help.

N.B. I'm running CentOS 6.2 with GNOME interface.

1
  • I wasn't running Gnome (or KDE either).
    – Hugh Allen
    Feb 23, 2012 at 8:21
-1

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.

You must log in to answer this question.

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