Typing accented latin alphabets in linux

Posted: October 6, 2013 in Tech Spot
Tags: , , , , ,

In this post, I will tell you how to type accented words (used in french, spanish) from your keyboard in linux. This is for the system using XKB (X KeyBoard extension) for key mapping. Almost all the system that uses xorg uses XKB. So, probably your system has a high likely hood of using XKB. To type the accented words like in french, a key called “compose key” must be set. Of course you have choice of setting any one key from the list of keys. For, example, to set the “left windows” key as the compose key, run the command,

 setxkbmap -option compose:lwin

here, on the above command, you are passing the option “compose:lwin” to setxkbmap command. As you must have guessed, “lwin” stands for left windows keys. You can also use ‘lalt’, ‘ralt’ for left and right alt keys. The list of keys you can use as compose keys can be found in “base.lst” file located in “/usr/share/X11/xkb/rules/base.lst”

You can view the contents of the file base.lst by running the command,

cat /usr/share/X11/xkb/rules/base.lst

it contains the list of compose keys.
Alternatively, to view only the compose keys from the file, you can pipe the output of the above command to grep with “compose” argument. So, to view only the compose keys that can be used, you can give the command,

cat /usr/share/X11/xkb/rules/base.lst | grep compose

The above command, lists only the line contains “compose” keyword.

Now, to set the compose key in your system, run,

setxkbmap -options compose:composekey

Here, replace the composekey with lwin/rwin/lalt/ralt or any other key that you may find in base.lst.

After setting up the compose key, now is the time to type the accented words.
For example, to type ‘é’ as in étudiant , first press the compose key, then ‘ (single quote) and then ‘e’ . So the combination is,
composekey + ” ‘ ” + “e” = é
Similarly for the alphabet ‘ç’ as in leçon, the combination is,
composekey + “,” + c = çand also, for ê – > composekey + “^” + e

Try experimenting the accented alphabets.

Note: This will work only for the current session. That is , when you log out and login again, you must again invoke the command “setxkbmap -options compose:lwin” to again make lwin as your compose key. To make it permanent (Well, not actually), put the above command in your .xinitrc file (before the exec command).

Here is the list of combinations of latin alphabets that you can type from your us keyboard : http://www.hermit.org/Linux/ComposeKeys.html


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s