Linux.com

Feature: Desktop Software

Adding extended character support

By Bruce Byfield on December 06, 2007 (4:00:00 PM)

Share    Print    Comments   

If you need to type a diacritical mark such as an acute "e" (é) -- let alone a character not found in a Western European language -- the standard English keyboard layouts for GNU/Linux users are barely ahead of those of typewriters. However, adding support for both extended characters and multiple keyboards has become much easier in the last few years. These days, you can quickly add extended character support from both GNOME and KDE, and, should either desktop fail you for any reason, you can fall back on other methods to improve your input.

Before you add the support you need, you should know the jargon of extended character support so you can navigate the available options. Extended character support depends on several different types of keys:

  • Deadkeys: Keys that do not print anything by themselves, but modify the next key that you press, usually adding a diacritical mark to them. For example, in many layouts, pressing the grave/tilde key (`/~ ) then a second key produces such characters as à or ã.
  • Compose, AltGraph, and multi_keys: Keys that change what is typed when you press the next key, just as the Shift key ordinarily prints upper-case letters instead of lower-. Usually, the AltGraph key is the right Alt key, while the Compose key is the right Windows or Menu key. The term "multi_key" is often used for the Compose Key in the X Window System. Generally only one of these keys is needed, although you could configure your system to have all three. The characters you can type with these keys are defined in /usr/X11R6/lib/X11/locale./locale name/Compose, but only some of the listings in the file will work on your particular system, so be prepared to experiment.
  • Third level chooser: In a standard English layout, all keys have a character they print normally, and one they print when the Shift key is held down. The third level chooser is the key you press to print a third character with a key. For instance, a layout might require you to press the third level chooser followed by the "y" key to type the sign for the yen (¥), or the "l" key for the British pound (£).

Any of these keys may be defined by the layout you select, or by your configuration choices. In both GNOME and KDE, the interface assumes you know what they mean.

GNOME and KDE support

The latest versions of GNOME and KDE have similar support for extended characters. In GNOME, keyboard options are available from the System -> Administration or System -> Preferences menu, the exact location depending on your distribution. In KDE, go to Regional and Accessibility -> Keyboard layout.

In either desktop go to the Layout/Layouts tab to enable multiple keyboard support for any of dozens of languages (the exact number depends on the distribution). Needless to say, you need a font capable of being used for the language you want. Changing keyboards requires that you log out and in again before the new choice takes effect.

If you are an English speaker and your main interest is being able to use the diacritical marks common to western European languages, you might want to select your default layout and look at the variants. For instance, in addition to Dvorak and other keyboard layouts, the variants for US English include three international variants: one with AltGraph and deadkeys, another with only deadkeys, and a third simply listed as Alternative International.

Unfortunately, none of these options may be useful. On my Fedora 8 installation, I could not get the AltGraph and deadkeys variant or the Alternative International options to work. The option with deadkeys worked, but had the disadvantage of requiring that you press the space bar if you want a plain apostrophe instead of an acute accent -- a change that can be remarkably hard to learn if you are a touch-typist.

Instead, I recommend you keep your existing layout and configure it from the Layout Options tab in GNOME or the Xkb Options tab in KDE. Besides options to change the behavior of the Caps Lock Key and numeric keypad, and for repositioning the Ctrl key, the Layout Option tab also contains several options that are useful for extended character support. One sets the key for switching between multiple layouts. Another defines the third level chooser, and can be used with another option to add support for typing the euro sign to one of several keys.

Most importantly, from either of these tabs, you can define your Compose key. This option works instantly without logging out. In my experience, it is the most useful option for extended character support.

The .Xmodmap solution

Until a couple of years ago, when extended character support started being built in to desktops, using .Xmodmap was the easiest way to add extended character support. It is still useful in cases where the GNOME and KDE settings all fail, as they did for me in Debian Lenny, or when you are using another graphical interface.

This solution requires a UTF-8 locale loaded on your system or desktop, and specified in /etc/X11/xorg.conf under the InputDevice section for your keyboard with a line like:

Option  "XkbLayout"  "en_US.utf8"

Then you need to define the multi_key. Open a command line, enter the xev command, then press the key you are configuring as a multi_key. Note its keycode in the command line; the keycode will vary with the keyboard.

Armed with the keycode, open a text editor and type the following line:

keycode <keycode> = Multi_key

Save the file under the name of .Xmodmap in your home directory, then either restart the X Window System or reboot to enable extended character support.

If it is not enabled after a reboot, check that you have the correct keyboard layout and a UTF-8 language defined in /etc/X11/xorg.conf. You should also remove the "nodeadkeys" option. You may need to define the multi_key in xorg.conf. For instance, to use the left Windows key, add the line:

Option  "XkbOptions"  "compose:lwin,grp:switch"

If you are using another key, all you have to change is the part that defines the key, replacing "lwin" with "rwin" for the right Windows key, or "ralt" for the right Alt key.

Advanced solutions

If none of these solutions gives you the character support you need, you have at least two alternatives. The classic support for multiple keyboards comes from SCIM (Smart Common Input Method). It is available in the repositories of many distributions, along with a selection of keyboards to use with it. SCIM is especially strong for Asian languages such as Chinese, Japanese, Korean, and Thai. Its main disadvantage is its involved setup, which is not helped by the fact that much of the project documentation is several years out of date -- although a guide for using SCIM with the latest Ubuntu release is available online.

A similar solution is KMFL (Keyboard Mapping for Linux), which Linux.com reviewed a couple of years ago. Based on SCIM, KMFL has an equally arduous setup. However, since it is written by the same company that produces the proprietary Keyman for Windows, KMFL may give access to a wider variety of layouts, especially if you need support for a lesser-known language.

At any rate, with all these solutions, extended character support for GNU/Linux is finally coming of age. Considering the imminent arrival of international Web addresses, it's about time.

Bruce Byfield is a computer journalist who writes regularly for Linux.com.

Share    Print    Comments   

Comments

on Adding extended character support

Note: Comments are owned by the poster. We are not responsible for their content.

Adding extended character support

Posted by: Anonymous [ip: 212.114.201.34] on December 06, 2007 05:15 PM
how about simply typing "setxkbmap de" (instead of "setxkbmap de nodeadkeys"), or any other country-code?

#

Adding extended character support

Posted by: Anonymous [ip: 213.222.172.220] on December 06, 2007 08:01 PM
yes i have a UK English notebook, and sometimes have to type in hungarian, my solution fire up terminal sexkbmap hu, and when done, sexkbmap gb.

#

Adding extended character support

Posted by: Anonymous [ip: 91.64.160.192] on December 07, 2007 01:04 PM
Well, your solutions work because you use latin languages. If you "setxkbmap bg" for example you'll end up typing cyrillic letters only and won't be able to switch back. Your only chance will be to have the "switch back" command in your shell history ;-)

#

Adding extended character support

Posted by: Anonymous [ip: 79.3.29.87] on December 08, 2007 07:28 AM
IMHO the simplest way to enable the compose key in Gnome is to bind it to the left "windows" key (that is otherwise unused AFAIK) by using the Gnome keyboard preferences applet, as show in this image http://tonelli.sns.it/pub/mennucc1/Compose_Keyboard_Preferences.png

#

Compose is different

Posted by: Anonymous [ip: 79.3.29.87] on December 08, 2007 08:35 AM
the above article errs in the description of how Compose works, where it says "Compose... just as the Shift key".

To you use the shift key, you hold it down while you type another key.

To use the Compose key: press and release it ; then press and release other two keys in sequence, and they will be combined to form one character.

Examples of combinations (where I list the two keys and the resulting char)

` a à
^ u û
, c ç
~ u ũ
- y ¥
/ o ø
- ( {
- n ñ
/ u µ

As you see , there is a wide choice of characters you can compose.

BTW: in Debian , "Compose" files are in /usr/share/X11 ; such as
/usr/share/X11/locale/iso8859-1/Compose

#

Adding extended character support

Posted by: Anonymous [ip: 79.3.29.87] on December 08, 2007 08:57 AM
The formatting of my previous post sucks, please see http://tonelli.sns.it/pub/mennucc1/compose.html

#

Adding extended character support

Posted by: Anonymous [ip: 194.169.228.3] on December 09, 2007 08:54 AM
You can find some more keyboard-layout-related information here: <a href="http://hektor.umcs.lublin.pl/~mikosmul/computing/articles/custom-keyboard-layouts-xkb.html">http://hektor.umcs.lublin.pl/~mikosmul/computing/articles/custom-keyboard-layouts-xkb.html</a>

#

US - intl Shortcoming

Posted by: Anonymous [ip: 198.144.206.152] on December 10, 2007 11:38 AM
Unfortunately, there is what I consider a bad design decision in the US/International layout. When it is selected, the '/" key defaults to the versions outside the normal us-ascii charset. Not that this is inherently bad, but all other "extra" characters are tied to the dead-key sequence, except these two. For these, you have to use the dead-key to get the "normal" versions. That is, the versions that most shells expect as quoting characters for command-lines!

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya