Difference between revisions of "Accents on US keyboards"

From ArchWiki
Jump to: navigation, search
(Key combinations)
(Environment variables)
Line 47: Line 47:
  
 
  export GTK_IM_MODULE=xim
 
  export GTK_IM_MODULE=xim
 +
 +
and/or
 +
 +
export XMODIFIERS="@im=none"
  
 
== xmodmap ==
 
== xmodmap ==
  
 
The {{Ic|xmodmap}} utility that is supplied with [[Xorg]] allows user to completely remap the keyboard. See [[xmodmap#Accents on US keyboards]] for more information.
 
The {{Ic|xmodmap}} utility that is supplied with [[Xorg]] allows user to completely remap the keyboard. See [[xmodmap#Accents on US keyboards]] for more information.

Revision as of 08:18, 29 May 2013

Typing in foreign languages such as French, Italian and German can be difficult on an American keyboard. To remedy this, Xorg provides options such as the compose key and the xmodmap utility.

XCompose

The compose key, when pressed in sequence with other keys, produces a Unicode character. E.g., in most configurations pressing <Compose> ' e produces é.

Compose keys appeared on some computer keyboards decades ago, especially those produced by Sun Microsystems. However, it can be enabled on any keyboard with setxkbmap. For example, compose can be set to right alt by running:

setxkbmap -option compose:ralt

If you want another key to be your Compose key, see /usr/share/X11/xkb/rules/base.lst at the compose: lines.

You may also edit your /etc/X11/xorg.conf.d/10-evdev.conf and change InputClass / 'evdev keyboard catchall' to look like this.

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
        Option "XkbOptions" "terminate:ctrl_alt_bksp,compose:ralt"
EndSection

Key combinations

By default, the compose key uses combinations defined in a file. The file used depends on the user's locale: an American using LC_CTYPE=en_US.UTF-8, for instance, would find the defaults in /usr/share/X11/locale/en_US.UTF-8/Compose.

Some of the default combinations are listed below:

Compose ` a : à
Compose ' e : é
Compose ^ i : î
Compose ~ n : ñ
Compose / o : ø
Compose " u : ü
Compose o c : ©
Compose + - : ±
Compose : - : ÷

However, you can define your own compose key combinations by copying the default file to ~/.XCompose and editing it. The compose key works with any of the thousands of valid Unicode characters, including those outside the Basic Multilingual Plane. However, GTK does not use xim by default and therefore does not follow ~/.XCompose keys. This can be fixed by forcing GTK to use xim by adding export GTK_IM_MODULE=xim to ~/.xprofile, or forcing individual apps to use xim by running them as GKT_IM_MODULE=xim command. However not all apps, such as Sublime-Text 2 know how to use xim, and so uim-scim can be used instead of xim once the scim-uim package is installed. Note that this was tested on KDE.

Environment variables

Some unfriendly applications (including many GTK apps) will override the compose key and default to their own built-in combinations. You can typically fix this by setting environment variables; for instance, you can fix the behavior for GTK with:

export GTK_IM_MODULE=xim

and/or

export XMODIFIERS="@im=none"

xmodmap

The xmodmap utility that is supplied with Xorg allows user to completely remap the keyboard. See xmodmap#Accents on US keyboards for more information.