How to do it: this experimental solution is a legacy issue - do not read it if you use newer systems

How to setup international keyboard in X Window with Xmodmap and XKB
Prev |  | Next

# 3. How to do it: this experimental solution is a legacy issue - do not read it if you use newer systems

Before the year 2000, I used the following way to customize keyboard in X Window System on some Unices. Put the following in your .bash_profile:

export LANG=language

OR

OR for csh shell

setenv LANG=langauge

and have the Xmodmap file in your home directory. If you ask me where you may obtain such Xmodmap files, some are in this HOWTO, or go to GNOME ../share directory. The file /usr/X11R6/lib/X11/locale/locale.alias contains the aliases for langauges, so look there in order to find out what is ca_ES or br_FR (the exact syntax for your language to use - you cannot write "croatia" but you must write "croatian", not "Croatian"; this is very important, as Unix is case sensitive).

Now you must install the pertinent language fonts and put path in XF86Config file to these fonts. If you want to internationalize your keyboard, use the standard Xmodmap definitions first and use right alt to switch between keyboards (if you use GNOME Xmodmap files). If it does not work, do the following:

a) Copy the "Compose" file from: /usr/X11R6/lib/X11/locale/iso8859-2 to: /usr/X11R6/lib/X11/locale/iso8859-1 directory (yes, iso8859-1, not iso8859-2). Back up the original "Compose" file if you want

b) Put the included .Xmodmap file to your root directory (Slovak language, or make your own .Xmodmap file, or choose from the ones listed here).

c) Install ISO8859-2 fonts (or other pertinent fonts).

You may try to issue the command:

xset q

to see which fonts are in your path.

If you want to add fonts in your path from the X Window System, issue the command:

xset fp+ /usr/fonts_path

xset fp rehash

d) Disable every "Scroll Lock" uncommented line in your XF86Config, because our .Xmodmap file for the Slovak language uses the Scroll Lock to switch between keyboards.

e) Put the appropriate fontpath for your newly installed fonts in the XF86Config file, if necessary (Mandrake 7.2 and other OS's may not require this). The Xmodmap solution may be applied to all X keyboards of your choice.

First, I must say that in my solution (in older XFree86 versions), different mapping, if used, appears to work for Xmodmap keycodes for some ISO8859-2 keycode entities. ISO8859-2 definitions (keycode entities) like lcaron, zcaron actually do not work. This means that the ISO8859-1 definitions must be used instead and they will either give you what they say they are (aacute [o?=, eacute [o?=, etc.), or they will not give you what they say they are (using ISO8859-2 fonts, putting "threequarters" in your .Xmodmap file will not give you "3/4" but "z" with a caron, a reversed ^ above it). For example, "mu" will give lcaron, "oslash" rcaron, etc.

However, other key definitions, for example, adieresis (a with two dots above it), uacute (u with a slash above it), as well as dead_diaeresis do not require a substitution of other definitions and work pretty well, as they're defined everywhere (a dead key is a key you press, hold it, yet nothing happens, but after pressing another key you will get a special letter).

The original "Compose" file in ../iso8859-1 directory can be fully utilized for English, Slovak or Czech keyboard layouts (Polish, Hungarian, Slovenian, Croatian) in some older XFree86 distributions, but there is only one problem - dead keys do not work. That's why you have to copy the "Compose" file from the iso8859-2 directory to iso8859-1 directory, or alternatively, you can edit the "Compose" file in iso8859-1 directory.

You can leave the Keyboard section in your XF86Config file without much change. Put (if it's not already there) the following in the "Keyboard" section:

Section "Keyboard"

Protocol "Standard"

XkbRules "xfree86"

XkbModel "pc101"

XkbLayout "us"

Force the system to read the xmodmap map by issuing the command: "xmodmap /.Xmodmap". Alternatively, you can have 60 .Xmodmap files like .Xmo1, .Xmo2, .Xmo3, .Xmo4, etc., and you may force the system to read them (xmodmap /.Xmo1). The dot means it is a hidden file and it is not necessary. You may also have xmo1, xmo2, or xmo3 Xmodmap files.

NOTE: If you are using some legacy programs like StarOffice 5.2, they have their own fonts, so Xmodmap solution will not work on older systems immediately with these applications. StarOffice 6.0 handles well conversion to win1250 and vice versa, so you can transport documents to a M$ platform. In my Mandrake 8.0, StarOffice 6.0 was internationalized immediately after using my standard Xmodmap solution. All the fonts worked. However, with StarOffice 5.2 this is not the case. In StarOffice 5.2, you must add X fonts to StarOffice's fonts directory. Here is a script that will do it for you. Cut it, name it "so52", make it executable (chmod +x so52), copy it to the StarOffice5.2/share/xp3 directory and execute it there.

-------------------------------cut_here-----------------------------------

#!/bin/sh

# Put path to your StarOffice here

STAR_OFFICE_ROOT=/mnt/StarOffice5.2

FONTS_DIR=/usr/X11R6/lib/X11/fonts/ISO8859-2/Type1

# -----------------------------------------------------------------------

# Don't edit the script here

# -----------------------------------------------------------------------

XP3_DIR=$STAR_OFFICE_ROOT/share/xp3

if [ -e $XP3_DIR/psstd.fonts.il2 ]; then

echo "Changes were already done!"

echo "If there's a problem, delete the file"

echo " $XP3_DIR/psstd.fonts.il2"

exit 1

fi

if [ -e $FONTS_DIR/afm ]; then

AFM_DIR=$FONTS_DIR/afm

else

AFM_DIR=$FONTS_DIR

fi

# Link AFM files.

ln -sf $AFM_DIR/*.[aA][fF][mM] $XP3_DIR/fontmetrics/afm

# Link PFB files.

ln -sf $FONTS_DIR/*.[pP][fF][bB] $XP3_DIR/pssoftfonts

grep "\.pf" $FONTS_DIR/fonts.dir \

| sed -e 's/\.pfb /, /g' -e 's/-0-0-0-0-/-%d-%d-%d-%d-/g' \

> $XP3_DIR/psstd.fonts.il2

cat $XP3_DIR/psstd.fonts.il2 >> $XP3_DIR/psstd.fonts

------------------------------------cut_here-----------------------------

StarOffice 5.2 fully recognizes Word97 documents even written in other languages, but a converter from iso8859-2 to win1250 encoding is necessary in order to transport ISO8859-2 documents to M$ platform. For html documents this is not necessary.

StarOffice 5.2 can be thus used by professional translators.

## 3.1. Xmodmap theory and Xmodmap solution

If you want to edit and make your own .Xmodmap keyboard layout definitions, I'll explain one line of the .Xmodmap file to make clear what you should do.

This example can be used for all keycodes. For example, the line:

keycode 0x11 = 8 asterisk aacute 8

(note: keycode 0x11 is derived from the "xkeycaps" utility; you can also use the X Window "xev" utility to explore keyboard puzzles.)

says that the first pair, the default one, (number "8" and "asterisk") will display number "8" when you press keycode 0x11 ("8"), will display asterisk when a "shift" key is pressed. After pressing the Scroll Lock, there's another definition: ISO_NEXT_GROUP, which means that when you press the default "8" key, no "8" will be displayed, but aacute (á); when you press the "shift" key, number "8" will be displayed. So if you change "aacute" and "8", anything you put instead of "aacute" and "8" will be displayed, for example:

keycode 0x11 = 8 asterisk semicolon colon

will give you "semicolon" and "colon" in your 0x11 keycode after pressing the Scroll Lock.

The ISO_NEXT_GROUP is defined by another line. If this line is not defined, you will be able to use only two definitions ("8" and "asterisk") - look at my .Xmodmap file. If you delete the ISO_NEXT_GROUP (the next pair of definitions on the right), you will have only one group of keyboard definitions ("8" and "asterisk"). Be careful when editing the .Xmodmap file. You mustn't delete definitions that enable utilization of the Scroll Lock unless you know what you are doing (or you map the second keyboard by right Alt). These are the lines such as:

keycode 0x4e = ISO_Next_Group

add mod5 = ISO_Next_Group,

etc. You must also keep in mind that Unices are case sensitive. If you want to find out more about keycodes, install the package "xkeycaps" or use "xev".

The following symbols on your right is what I found out through my research. This is just an example. When you use a "Pound" definition in the Xmodmap file, the X Window System will display you a Lslash instead (in relation to using iso8859-2 fonts, of course). When you choose some easy KDE text editor, select iso8859-2 fonts charset from the fonts menu. NOTE: vowel *acute (uacute, eacute, etc.) signs require no substitution, therefore I omitted iacute, aacute, etc., here.

ISO8859-1 entity will give you the: ISO8859-2 entity

in our nonstandard or experimental Xmodmap keycode definition

egrave ccaron

ugrave uring

agrave racute

ecircumflex "c" with something at the bottom of it

ucircumflex Lslash "Pound" in Xmodmap gives you Lslash.

Lcaron Writing "yen" will give us Lcaron

Scaron copyright (will give us Scaron)

Tcaron guillemotleft (will give us Tcaron)

Zcaron registered

lcaron mu

scaron onesuperior

tcaron guillemotright

zcaron threequarters

Cacute AE

Eogonek find out yourself

Edieresis Edieresis

ecaron igrave

onequarter zacute

questiondown z with a ring above it

Dcaron find out yourself

Ooblique Rcaron

thorn t with something at the bottom of it

Sterling Lstroke

yen Lcaron

copyright Scaron

brokenbar Sacute

macron Z with something above it

paragraph sacute

periodcentered caron

masculine s with something at the bottom of it

onequarter zacute

ecircumflex d with a line above it

ETH Dstroke

Ntilde Nacute

Otilde O with two dots above it

registered Zcaron

Nacute Ograve

nacute ograve

Ocircumflex Ocircumflex

ccaron egrave

nacute ntilde ------------------------------------------------------------------------

## 3.2. Experimental .Xmodmap sample file for the Slovak language typewriter layout

You may use this file as an example to build your own xmodmap keyboard layouts. _______________________cut_here_________________________

keycode 0x09 = Escape

keycode 0x43 = F1 F11 F1 Multi_key

keycode 0x44 = F2 F12 F2 F12

keycode 0x45 = F3 F13 F3 F13 idiaeresis

keycode 0x46 = F4 F14 F4 F14 mu yen

keycode 0x47 = F5 F15 F5 F15 guillemotright guillemotleft

keycode 0x48 = F6 F16 F6 F16 ograve

keycode 0x49 = F7 F17 F7 dead_abovedot oacute

keycode 0x4A = F8 F18 F8 dead_breve acute

keycode 0x4B = F9 F19 F9 dead_cedilla ugrave

keycode 0x4C = F10 F20 F10 dead_ogonek

keycode 0x5F = F11 F21 dead_acute dead_caron

keycode 0x60 = F12 F22 dead_abovering dead_diaeresis

keycode 0x6F = Print Execute dead_iota

keycode 0x4E = ISO_Next_Group

keycode 0x6E = Pause

keycode 0x31 = grave asciitilde semicolon dead_diaeresis

keycode 0x0A = 1 exclam plus 1

keycode 0x0B = 2 at mu 2

keycode 0x0C = 3 numbersign onesuperior 3

keycode 0x0D = 4 dollar egrave 4

keycode 0x0E = 5 percent 0x0bb 5

keycode 0x0F = 6 asciicircum threequarters 6

keycode 0x10 = 7 ampersand yacute 7

keycode 0x11 = 8 asterisk aacute 8

keycode 0x12 = 9 parenleft iacute 9

keycode 0x13 = 0 parenright eacute 0

keycode 0x14 = minus underscore equal percent

keycode 0x15 = equal plus dead_acute dead_caron

keycode 0x33 = backslash bar ograve parenright

keycode 0x16 = BackSpace

keycode 0x6A = Insert

keycode 0x61 = Home

keycode 0x63 = Prior

keycode 0x4D = Num_Lock Pointer_EnableKeys

keycode 0x70 = KP_Divide slash

keycode 0x3F = KP_Multiply asterisk

keycode 0x52 = KP_Subtract minus

keycode 0x17 = Tab ISO_Left_Tab

keycode 0x18 = q Q

keycode 0x19 = w W

keycode 0x1A = e E

keycode 0x1B = r R

keycode 0x1C = t T

keycode 0x1D = y Y z Z

keycode 0x1E = u U

keycode 0x1F = i I

keycode 0x20 = o O

keycode 0x21 = p P

keycode 0x22 = bracketleft braceleft uacute slash

keycode 0x23 = bracketright braceright adiaeresis parenleft

keycode 0x24 = Return

keycode 0x6B = Delete

keycode 0x67 = End

keycode 0x69 = Next

keycode 0x4F = KP_Home 7 KP_Home

keycode 0x50 = KP_Up 8

keycode 0x51 = KP_Prior 9

keycode 0x56 = KP_Add plus

keycode 0x42 = Caps_Lock

keycode 0x26 = a A

keycode 0x27 = s S

keycode 0x28 = d D

keycode 0x29 = f F

keycode 0x2A = g G

keycode 0x2B = h H

keycode 0x2C = j J

keycode 0x2D = k K

keycode 0x2E = l L

keycode 0x2F = semicolon colon ocircumflex quotedbl

keycode 0x30 = apostrophe quotedbl section exclam

keycode 0x53 = KP_Left 4

keycode 0x54 = KP_Begin 5

keycode 0x55 = KP_Right 6

keycode 0x32 = Shift_L ISO_Next_Group

keycode 0x34 = z Z y Y

keycode 0x35 = x X

keycode 0x36 = c C

keycode 0x37 = v V

keycode 0x38 = b B

keycode 0x39 = n N

keycode 0x3A = m M

keycode 0x3B = comma less comma question

keycode 0x3C = period greater period colon

keycode 0x3D = slash question minus underscore

keycode 0x3E = Shift_R

keycode 0x62 = Up

keycode 0x57 = KP_End 1

keycode 0x58 = KP_Down 2

keycode 0x59 = KP_Next 3

keycode 0x6C = KP_Enter Return

keycode 0x25 = Control_L ISO_Next_Group

!keycode 0x40 = Alt_L Meta_L

keycode 0x40 = Meta_L Alt_L

keycode 0x41 = space

keycode 0x71 = Alt_R Meta_R

keycode 0x6D = Control_R

keycode 0x64 = Left

keycode 0x68 = Down

keycode 0x66 = Right

keycode 0x5A = KP_Insert 0

keycode 0x5B = KP_Delete period

!keysym Alt_L = Meta_L

!keysym F12 = Multi_key

clear Shift

!clear Lock

clear Control

clear Mod1

clear Mod2

clear Mod3

clear Mod4

clear Mod5

add Shift = Shift_L Shift_R

add Control = Control_L Control_R

!add Mod1 = Alt_L Alt_R

add Mod1 = Meta_L Alt_R

add Mod2 = Num_Lock

add Mod5 = ISO_Next_Group

!add Mod1 =

!add Mod2 = Alt_R Alt_L Mode_switch

keycode 0x73 = ISO_Next_Group

keycode 0x74 = dead_acute dead_diaeresis

keycode 0x75 = dead_caron dead_abovering

_____________________________cut_here_____________________________

You may find almost any xmodmap file in the GNOME directory in (SuSE) /opt/gnome/share/xmodmap (with standard ISO8859-1,2 and other definitions). To switch between the keyboards, use right Alt.

Prev | Home | Next
Setting up international keyboard in X Window System with Xmodmap and XKB |  | Xmodmap theory and Xmodmap solution