ALINK="#FF0000">

LINUX GAZETTE

[ Prev ] [ Table of Contents ] [ Front Page ] [ FAQ ] [ Talkback ] [ Next ]

Talkback: Discuss this article with peers

"Linux Gazette...making Linux just a little more fun!"


Setting Up International Keyboards

By Juraj Sipos


This xmodmap and kimap solutions will work for you in setting up any international keyboard for (Debian, RedHat, Mandrake, Corel Linux) Linux, FreeBSD, OpenBSD, NetBSD and possibly every Unix that uses Xfree86 and KDE. The advantage of this package is that it is not architecture specific and will work on SPARK, MIPS and all other systems. I don't want to say that other packages are architecture independent, but I don't like writing garbage in the bash_profile and XF86Config or possibly somewhere else. This was written by Juraj Sipos (c) on 4/22/2000, xvudpapc@savba.sk

INTRODUCTION

Imagine you use Linux or a BSD OS and want to write a business letter to a person that has a foreign name with a slash or idiaresis. Danish language uses signs like ø and Portuguese like ñ. With this information you can make your own international keyboard layout without installing any additional packages. The following information will help you set up German, Spanish, Italian, Slovak, Czech, Polish, Slovenian, Croatian, Danish, Dutch, French, Finnish, Norwegian, Estonian, Latvian, Swedish and other keyboards without additional installing of national packages and without writing garbage to bash_profile and XF86Config files. You can also alternatively look at my homage at http://www.home.sk/www/man/bsd1.htm
to see pictures of various keyboards. In case you want to install Greek, Hebrew or Russian language, follow my information and apply changes pertinent to these languages (e.g., to install Greek fonts, etc.).

The biggest problem with kikbd or international keyboard under KDE in X Windows is that it doesn't work in Xfree86 that easily (you have to install some national packages and write garbage with complicated syntax to the above-mentioned files). A user expects a simple way for configuring his or her keyboard for international settings. A simple way is to start KDE, change the international keyboard settings and immediately write in the language we chose (this will work for German and other languages, but in Eastern European keyboards some letters don't function). According to the KDE documentation it should work, but it doesn't. After exploring many KDE resources on the net, I didn't find a solution (except for the one that forces you to install some national package). I know that some locale settings should be included in my bash_profile or csh logic scripts, but after applying these settings I couldn't change (and install) keyboards in FreeBSD and it appeared like going through a darker forest compared to the information I already had regarding localization of KDE and X Windows under Xfree86.

Here are some solutions for installing international keyboard layouts.  The following information will help you set up any European keyboard layout. The solution works for Xfree86 in 3.1 RELEASE in FreeBSD (.Xmodmap solution), Corel Linux, Debian Linux, RedHat and FreeBSD 3.3 RELEASE and 4.0 RELEASE (KDE *.kimap solution). I tested it on those systems. Note: .Xmodmap solution works well with other windows managers. Some Unixes override .Xmodmap setting when used with KDE. If .Xmodmap doesn't work, change must be made to the KDE kimap files in .../kikbd directory.

If .Xmodmap solution doesn't work in KDE, copy skz.kimap (at the end of this article) to /usr/local/share/apps/kikbd, which is your KDE keyboard directory. The problem with KDE is that after installing another keyboard, you have no chance to use it as KDE documentation doesn't clearly state how to define your locale settings in a bash_profile. After I installed Slovak keyboard in KDE, I couldn't write in Slovak or Czech, so I made few changes to skz.kimap file, which are explained later in this file. After applying these changes, no other changes are necessary - you don't need to write any special commands to your bash_profile or XF86Config. BUT WHEN YOU INSTALL ANOTHER KEYBOARD in START/SETTINGS/INPUT DEVICES/INTERNATIONAL KEYBOARDS from your KDE menu, CHECK AUTOSTART. Then everything will work fine.  The difference between skz.kimap and sky.kimap (and csz.kimap and csy.kimap) is that y,Y and z,Z are swapped, so with skz.kimap or csz.kimap you will have z,Z instead of y,Y, but with sky.kimap or csy.kimap, y,Y doesn't change its position on the IBM English keyboard layout.

How it all works:

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 (alternatively, copy other iso885*** Compose
   file to iso8859-1 directory).
b) Put the included .Xmodmap file to your root directory (Slovak language, or make your own
   .Xmodmap file) (or possibly put your own *.kimap file to the kikbd directory if Xmodmap
   will not work)
c) Install ISO8859-2 fonts (or other pertinent fonts).
d) Disable every "Scroll lock" uncommented line in your XF86Config, because our .Xmodmap
   uses scroll lock to switch between keyboards.
e) Put the appropriate fontpath for your newly installed fonts in your XF86Config file, if
   necessary.

The .Xmodmap solution may be applied to all  X keyboards except Hebrew, I suppose (I'm joking). The .Xmodmap file overrides all settings of keyboard layouts as defined in /usr/X11R6/lib/X11/xkb/symbols/, where are symbols for many international keyboards. The .Xmodmap solution will give you an enhanced Slovak typewriter keyboard layout.

First, I must say that in my solution, different mapping is used for .Xmodmap file (and kimap file) for some ISO definitions. This means that the ISO definitions will either give you what they say they are (aacute [á], eacute [é], etc.), or they will not give you what they say they are (putting "threequarters" in your .Xmodmap file will give not give you "3/4" but "z" with a caron above it). For example, "mu" will give lcaron, "oslash" rcaron, etc. (Obviously, in other case you need to install some national packages to use "lcaron" definition instead of "mu"). Normally, you can not put "lcaron" to the .Xmodmap file, because it will not give you lcaron; you must write "mu" instead, or "guillemotright" for tcaron. I also tried hexadecimal numbers and they work. However, other  key definitions, for example, adieresis (a with two dots above it), uacute (u with 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 (dead key is a key  you press, you hold it and 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 Slovak or Czech keyboard layouts (Polish, Hungarian, Slovenian, Croatian), but there is only one problem with the Slovak or Czech keyboard (and other languages too) layout - dead_caron doesn't 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 and put all references about "dead_caron" from iso8859-2/Compose to iso8859-1/Compose file.

You can leave the Keyboard section in your XF86Config 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"

Some X Windows managers and/or environments override .Xmodmap settings, so if you use KDE and .Xmodmap doesn't work, use kikbd keymap instead of .Xmodmap. (A sample kikbd kimap for the Slovak language is included at the bottom of this file). The Slovak/Czech/English keyboard layout  is switched to by scroll lock with .Xmodmap. You may use languages only with the applications that have access to your ISO-8859-2 (or other fonts) fonts (this may not work with StarOffice or with other applications that have their own built-in fonts). StarOffice has its own fonts directory - afm fonts in ../xp3/fontmetrics/afm, and ps fonts in ../xp3/pssoftfonts, so you must add the ISO8859-2 fonts directory to these directories (to tell StarOffice to use these fonts too) and edit fonts.dir file and add the symlinked fonts there. I can easily use any language in StarOffice.

Important note: If you want to exchange documents between StarOffice or WordPerfect and MS Word, you must include the information about windows 1250 encoding to the file you write (win1250 is similar to iso8859-2, but it's a little bit different). There's a solution: use a converter from iso8859-2 to win1250 (you can find one at my home page at http://www.home.sk/www/man/bsd1.htm).

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 explanation can be used for all keycodes.

For example, the line:

keycode 0x11 = 8 asterisk aacute 8

(note: keycode 0x11 is derived from xkeycaps utility)
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. 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. These are the lines such as:

keycode 0x4e = ISO_Next_Group
add mod5 = ISO_Next_Group

etc. You must also keep in mind that Unixes are case sensitive.

If you want to find out more about keycodes, install a package "xkeycaps".

________________cut_here__________________________________________________

! This is an `xmodmap' input file for PC 101 key #2 (FreeBSD/XFree86; US)
! keyboards created by XKeyCaps, modified by Juraj Sipos on 8/17/1999.
! XKeyCaps 2.38 is Copyright (c) 1997 Jamie Zawinski <jwz@netscape.com.
! http://people.netscape.com/jwz/xkeycaps/ This is an .Xmodmap solution for
! Slovak keyboard. You must have ISO-8859-2 fonts installed with a
! pointer in /etc/XF86Config
! NOTE: "!" is a comment. Some information follows but I deleted
! it as it is commented and not important.
! If you want to know what I deleted, start xkeycaps utility and generate your
! own Xmodmap file.
! The "0 Ins" key generates KP_Insert and KP_0
! The ". Del" key generates KP_Delete and KP_Decimal

!#define XK_dead_semivoiced_sound 0xFE5F

!dead_iota, dead_voiced_sound, dead_belowdot, dead_tilde, dead_macron

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_doubleacute dead_circumflex
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 acute slash
keycode 0x23 = bracketright braceright diaeresis 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__________________________________________________________

# KDE skz.kimap Config File, modified by Juraj Sipos
# name this file as skz.kimap and copy it to KDE .../kikbd directory

[International Keyboard]
Label=Skz
Locale=sk

# *** here was some info I deleted.

[KeyboardMap]
CapsSymbols=q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m
keysym0=1,plus,1,exclam,,
keysym1=2,mu,2,at,,
keysym2=3,onesuperior,3,numbersign,,
keysym3=4,egrave,4,dollar,,
keysym4=5,0x0bb,5,percent,,
keysym5=6,threequarters,6,asciicircum,,
keysym6=7,yacute,7,ampersand,,
keysym7=8,aacute,8,asterisk,,
keysym8=9,iacute,9,parenleft,,
keysym9=0,eacute,0,parenright,,
keysym10=minus,equal,percent,minus,underscore,
keysym11=grave,dead_diaeresis,dead_circumflex,grave,asciitilde,
keysym12=equal,dead_acute,dead_caron,equal,plus,
keysym13=bracketleft,uacute,slash,bracketleft,braceleft,
keysym14=bracketright,adiaeresis,parenleft,bracketright,braceright,
keysym15=semicolon,ocircumflex,quotedbl,semicolon,colon,
keysym21=y,z,Z,,,
keysym22=z,y,Y,,,
# I changed some keysyms above (as "mu" instead of "lcaron") and added the following lines
keycode43=51,ograve,parenright,backslash,bar,
keycode40=48,section,exclam,apostrophe,quotedbl,
keycode51=59,comma,question,less,comma,
keycode52=60,period,colon,period,greater,
keycode53=61,minus,underscore,slash,question,
____cut_here___________________________________________________________________________

(The numbers of keycodes are derived from the "xkeycaps" utility)

The purpose of the following info is to help you build any .Xmodmap keyboard layout with iso8859-2 or other character sets.  If you're going to use other languages than the Central European ones, find a pertinent table for your ISO*** character set on Internet. The gdkkeysyms.h file is in (RedHat) /usr/include/gdk/gdkkeysyms.h and it contains all the special names we're using here (it also contains names of Greek characters).

UNIX

ISO-8859-2 (ISO Latin2) character set

octal hex (you can use it for other languages too)

----------------------------------------------------------------------
First, try to see if definitions will give you (after installing pertinent fonts and keyboard in X) what they say they are. If they will not give you what they say they are (some keycodes will be unfunctional), then you must make a substitution. Definitions which will not give you what they say they are can be traced by their visual shape in Western Latin 1 encoding. For example, if you load a Slovak website, do not use ISO8859-2 character set encoding for viewing, but Western ISO8859-1 encoding for viewing. Thus you will see bad fonts with letters like ¾ and so on. You will see what you must substitute. But if you don't know what "¾" is called in ISO terminology, find and download an appropriate character set table for ISO-8859-1. It must be somewhere on the net. The symbols on your right (for example, mu [micro], which is µ, will give you lcaron instead of µ) will give you what's on their left. NOTE: vowel *acute signs require no substitution, therefore I omitted iacute (í), aacute (á), etc. 

0243 0xa3 /Lslash £     (Explanation: writing the name of £ ["pound" in our case]
                        to Xmodmap or kimap file will give you Lslash. But Lslash can be
                        obtained by a dead_caron - you press a dead_caron and L). The sign
                        on the right, if put in Xmodmap or kimap files, will
                        print you the character which is on its left
0245 0xa5 /Lcaron ¥     Thus, writing "yen" to kimap or Xmodmap file will give us Lcaron
0251 0xa9 /Scaron ©     copyright (will give us Scaron)
0253 0xab /Tcaron «     guillemotleft (will give us Tcaron)
0256 0xae /Zcaron ®     registered
0265 0xb5 /lcaron µ     mu
0271 0xb9 /scaron ¹     onesuperior
0273 0xbb /tcaron »     guillemotright
0276 0xbe /zcaron ¾     threequarters
0306 0xc6 /Cacute Æ     find out yourself
0312 0xca /Eogonek Ê    find out yourself
0313 0xcb /Edieresis Ë  Edieresis
0314 0xcc /Ecaron Ì     find out yourself
0317 0xcf /Dcaron Ï     find out yourself
0321 0xd1 /Nacute Ñ     Ograve
0322 0xd2 /Ncaron Ò     find out yourself
0324 0xd4 /Ocircumflex Ô Ocircumflex
0325 0xd5 /Ohungarumlaut Õ find out yourself
0330 0xd8 /Rcaron Ø     find out yourself
0331 0xd9 /Uring Ù      find out yourself
0333 0xdb /Uhungarumlaut Û
0336 0xde /Tcedilla Þ
0343 0xe3 /abreve ã
0345 0xe5 /lacute å
0346 0xe6 /cacute æ
0350 0xe8 /ccaron è    egrave
0352 0xea /eogonek ê
0354 0xec /ecaron ì
0357 0xef /dcaron ï
0361 0xf1 /nacute ñ    ntilde
0362 0xf2 /ncaron ò
0365 0xf5 /ohungarumlaut õ
0370 0xf8 /rcaron ø
0371 0xf9 /uring ù
0373 0xfb /uhungarumlaut û
0376 0xfe /tcedilla þ
0377 0xff /dotaccent ÿ

You may experiment to find out which definitions will give you which characters, it shouldn't be difficult. This is just a hint on how to start. I didn't go on to investigate further definitions because I have my Slovak and Czech keyboards and I'm not, for now, interested to use other keyboards.  Look at my homage and build your own keyboard.
 

Enjoy.
Juraj Sips


Copyright © 2000, Juraj Sipos
Published in Issue 53 of Linux Gazette, May 2000

Talkback: Discuss this article with peers

[ Prev ] [ Table of Contents ] [ Front Page ] [ FAQ ] [ Talkback ] [ Next ]