LF Tip: Changing the keyboard layout on the fly

ArticleCategory:

UNIXBasics

AuthorImage:[Here we need a little image from you]

[Photo of the Author]

TranslationInfo:[Author + translation history. mailto: or http://homepage]

original in en Guido Socher

AboutTheAuthor:[A small biography about the author]

Guido likes Linux because of the community. It is a huge project and somehow all the different people around the world are working towards the same goal: Making it better every day.

Abstract:

This is a small tip. From now on LinuxFocus will have at least one new tip every month. If you have some ideas for a new tip then send them to guido(Q)linuxfocus.org

ArticleIllustration:

idea

ArticleBody:

Introduction

When I write a text on the computer I have my eyes on the screen and not the keyboard. Recently I visited a friend in France and he borrowed me his computer for a while. French keyboard layout! It took at least 10 seconds per key to find it because I am used to US or German keyboards ;-)
I did not want to edit the /etc/X11/XF86Config-4 as it was his PC. .... KDE and Gnome have some tools to change the keyboard layout but it did not seem to be installed here. What now?

The solution

XFree86 has a standard command called setxkbmap which you can use to change the layout on the fly (no X server restart). It is similar to the loadkeys command on the Linux console.
I typed:

setxkbmap -layout us

and voila I had a US keyboard layout. Before
I gave to computer back to my friend I just typed:

setxkbmap -layout fr

and it was as if nothing was changed.