Hi,

I have created and used a keymap for romanized Singhala. A group of us have been using it for some years now and it is stabilized with tests and updates. We want to add it either as a variant to 'lk' layout or as a new layout file specified for 'romanized' (South Asian) languages. (Singhala is the template. Hindi is on the way.) Our tutorial on how to add the keymap is attached for your scrutiny. This is too hard for most ordinary users.

So, how do we go about doing this, please?

Best regards,

JC


*****************************************************************
*****************************************************************
******************** LINUX KEYBOARD TUTORIAL ********************
*****************************************************************
*****************************************************************

Keyboard, keymap, layout all refer to the same thing. Layout is kind of the 
formal one used by all platforms. 

Linux keymaps are defined under the X11 system. There are three files involved 
in making a keymap, at least in the three distros I tested (Slacko Puppy and 
two flavors of Ubantu: Kubuntu and Mint Rebecca).

In Slacko Puppy, the X11 directory is in its classic location: /etc/X11
In Kubuntu and Mint Rebecca, it is at: /usr/share/X11

We usually define our keymaps inside layout files named for countries: us, af 
etc. We can also place them inside special purpose layout files named 
appropriately, for instance, 'romanized' meaning 'all romanized keymaps go 
inside here'. So, a layout file can contain more than one keymap definition. 

The first tutorial is how to make a special purpose keymap inside its own 
layout file, may be for your own personal use and testing. The second one tells 
how to add a keymap to an existing layout file. But first, on editing files...


*******************************************
********** EDITING SYSTEMS FILES **********
*******************************************

Except in Puppy, you need special permission to edit system files.



***** Slacko Puppy *****
(Perhaps it is possible to have the pattern of file system follow that of the 
distro a particular branch of Puppy feeds out of)

The layout files in my Slacko Puppy are in /etc/X11/xkb/symbols/pc/



***** Ubuntu *****
Layout file location: /usr/share/X11/xkb/symbols/

KUBUNTU
In Kubuntu, you cannot edit files in situ. At least, I couldn't. I first 
created the keymap on the desktop and copied the two required files in the 
'rules' folder to the desktop as well. Then I copied them to their respective 
locations using the cp copy command inside the terminal window. In order to get 
the ability to copy them, I changed my credentials to that of root by using the 
command 'sudo su-' and supplying the password. It will stay blank, with no clue 
if it is accepting your input — the Linux poker face.

The terminal commands I used in Kubuntu to copy a file edited on Desktop to 
location:

sudo su-
[type your password]
cp /home/[user-name]/Desktop/[layout-file-name]  
/usr/share/X11/xkb/symbols/[layout-file-name]

For the other two files that we will discuss later, the file path changes 
replacing 'symbols' to 'rules'.


LINUX MINT
What a relief! Open the directory (folder) of the file you want to edit, 
right-click on a blank area and select 'Open as Root'. It even shows the dots 
for password! The folder will open in a new window with a red bar at top. Just 
create or edit the file right there. Caveat: Before editing a file, I'd open it 
from a regular folder without root privileges. This way, you have the original 
in read-only mode to get back to, in case Mint messes up your typing by 
suddenly whisking away the cursor to some other place. This is a bug in Mint on 
my computer. Even so, Mint is the best one to test the changes because it 
displays an error box on start up or when you try to set up a layout variant 
using keyboard settings. The other two would stay silent with errors.



****************************************************
****************************************************
********** 1. MAKING A STAND-ALONE LAYOUT **********
****************************************************
****************************************************

Below is the contents of the standalone layout map I tested. (Look toward the 
bottom past two double lines for the number 2 tutorial on how to add a keymap 
to an existing layout file). I named this layout file 'romanized' and placed it 
as follows:

FILE LOCATION
Puppy: in X11/xkb/symbols/pc/romanized
Ubuntu (Kubuntu & Mint): X11/xkb/symbols/romanized

Read explanations below the ending asterisk lines. (Skip the // comment lines 
to get to the meat that starts with the word 'default').



****************************** BEGIN SAMPLE KEYMAP 
******************************
// SINGHALA - DUAL-SCRIPT (ROMANIZED SINGHALA)
// ===========================================
//
// This keymap is made for fast typing romanized Singhala. Only three keys
// produce letters different from those stamped on key caps:
// Q -> Edh (ð), W -> Ash (æ), F -> Thorn (þ).
// 
// It provides the accent marks necessary to type (Latin) PTS Pali as well:
// Dead keys:
// AltGr-1 = bar for long vowels, AltGr-2 = dot below (for muurdhaja) and
// AltGr-3 = above dot (for Anusvara m)
//
// And some handy characters...
// AltGr-5 = UB0 = degree sign; AltGr-minus = em-dash;
// AltGr-< and AltGr-> = UAB and UBB = left and right double angle quotes.
//
// This keyboard can be used to type Singhala, Sanskrit and Pali to yield text
// in the traditional Singhala script when used in conjunction with a Singhala
// smartfont.
//
// The font below can be used to type in the traditional Singhala script using
// the phoneme chart (Singhala: 'hodiya' Sanskrit: 'soDI'):
// smartfont: http://smartfonts.net/singhala/anura.ttf
// hodiya: http://ahangama.com/hodiya/hodiya3.htm
//
// Dedication:
// Rev. Fr. A. M. Gunasekara, Rev. Fr. Theodore G. Perera
// Ven. Gnanaponika, Ven. Mettavihari
//
// Maintainer:
// JC Ahangama - s...@ahangama.com
//
default partial alphanumeric_keys modifier_keys
xkb_symbols "singhala" {
  name[Group1]= "Singhala";
  include "us(basic)"
  include "level3(alt_switch)"
//
//                   UNSHIFTED,         SHIFT,           ALT
//                   --------------------------------------------
//
  key <TLDE> { [         grave,    asciitilde,    VoidSymbol ] };
  key <AE01> { [           one,        exclam,   dead_macron ] };
  key <AE02> { [           two,            at, dead_belowdot ] };
  key <AE03> { [         three,    numbersign, dead_abovedot ] };
  key <AE04> { [          four,        dollar,      currency ] };
  key <AE05> { [          five,       percent,           UB0 ] };
  key <AE06> { [           six,   asciicircum,    onequarter ] };
  key <AE07> { [         seven,     ampersand,       onehalf ] };
  key <AE08> { [         eight,      asterisk, threequarters ] };
  key <AE09> { [          nine,     parenleft,    VoidSymbol ] };
  key <AE10> { [          zero,    parenright,    VoidSymbol ] };
  key <AE11> { [         minus,    underscore,         U2014 ] };
  key <AE12> { [         equal,          plus,    VoidSymbol ] };

  key <AD01> { [           eth,           ETH,             q ] };
  key <AD02> { [            ae,         acute,             w ] };
  key <AD03> { [             e,        eacute,    ediaeresis ] };
  key <AD04> { [             r,   ucircumflex,    VoidSymbol ] };
  key <AD05> { [             t,    VoidSymbol,    VoidSymbol ] };
  key <AD06> { [             y,    VoidSymbol,    VoidSymbol ] };
  key <AD07> { [             u,        uacute,    udiaeresis ] };
  key <AD08> { [             i,        iacute,    idiaeresis ] };
  key <AD09> { [             o,        oacute,    odiaeresis ] };
  key <AD10> { [             p,    VoidSymbol,    VoidSymbol ] };
  key <AD11> { [   bracketleft,     braceleft,    VoidSymbol ] };
  key <AD12> { [  bracketright,    braceright,    VoidSymbol ] };

  key <AC01> { [             a,        aacute,    adiaeresis ] };
  key <AC02> { [             s,    VoidSymbol,    VoidSymbol ] };
  key <AC03> { [             d,             D,    VoidSymbol ] };
  key <AC04> { [         thorn,             f,    VoidSymbol ] };
  key <AC05> { [             g,             G,    VoidSymbol ] };
  key <AC06> { [             h,    VoidSymbol,    VoidSymbol ] };
  key <AC07> { [             j,      ccedilla,    VoidSymbol ] };
  key <AC08> { [             k,    VoidSymbol,    VoidSymbol ] };
  key <AC09> { [             l,             L,   ocircumflex ] };
  key <AC10> { [     semicolon,         colon,    VoidSymbol ] };
  key <AC11> { [    apostrophe,      quotedbl,    VoidSymbol ] };

  key <AB01> { [             z,    VoidSymbol,    VoidSymbol ] };
  key <AB02> { [             x,    VoidSymbol,    VoidSymbol ] };
  key <AB03> { [             c,      ccedilla,    VoidSymbol ] };
  key <AB04> { [             v,    VoidSymbol,    VoidSymbol ] };
  key <AB05> { [             b,             B,    VoidSymbol ] };
  key <AB06> { [             n,             N,        ntilde ] };
  key <AB07> { [             m,    VoidSymbol,    VoidSymbol ] };
  key <AB08> { [         comma,          less,           UAB ] };
  key <AB09> { [        period,       greater,           UBB ] };
  key <AB10> { [         slash,      question,         U200C ] };
  key <AB11> { [     backslash,           bar,    VoidSymbol ] };

  key <BKSL> { [         space,           UA0,    VoidSymbol ] };
};
******************************* END SAMPLE KEYMAP 
*******************************

// slashes: These mean that those lines do not count in compiling the layout. 
Therefore, the first valid program statement is the two lines,
default partial alphanumeric_keys modifier_keys
xkb_symbols "singhala" {

key <TLDE> etc. are KEYCODES representing the keys on the physical keyboard. 
The items inside curly brackets {} are the key values according to key press 
'Level'. Looking at the keymap, the UNSHIFTED is Level 1, SHIFTED is Level 2 
and Level 3 is the ALT column.

KEY WORDS
default:
This is used only for one keymap in a layout file, and is usually the first one 
in the file. If there are secondary keymaps or variants in this layout file, 
they omit this word from this line.

partial: There may be other keys that do things not defined here

modifier_keys: Shifted keys exist

xkb_symbols: Name of this particular keymap

name[Group1]: This is the name of the variant you see when setting up the 
keyboard

include: Include a keymap from another layout file.
include "us(basic)": Says that that the variant 'basic' inside the 'us' layout 
file
shines through keys that are not explicitly defined on this keymap.
My keymap defines every key position that 'us(basic)' defines. Therefore, this 
programming statement is redundant in my case.
include "level3(alt_switch)": Tells to enable key selection by depressing 
either Alt key including AltGr (alternate graphic) key as stamped on European 
keyboards. This definition is in the 'level3' layout file. There is also a 
"level3(ralt_switch)" with an 'r' telling to use only the AltGr key on the 
right for this purpose like in Windows systems.

DEFINING KEY NAMES
As long as they are ASCII keys, you can simply type the actual key instead of 
the English names. Please see the 'us' layout file. It has 1, 2 in place of 
'one', 'two' I used here. Notice that I have UAB, U200C etc. They came from 
http://www.unicode.org/charts/. The short ones are from the Basic Latin (ASCII) 
code block. These single byte codes need not have leading zeros.

I think the most stable keymap would be defined using the Unicode codes, though 
the chance of you making mistakes is high. Remember to keep the 'U' capital. It 
means that it is a character listed in the Unicode character database.

VoidSymbol: Says to ignore this key press. I have seen 'NoSymbol' used too. 
That did not come out as too reliable to me.





*******************************************************
********** EDITING base.xml / evdev.xml FILE **********
*******************************************************

FILE LOCATION
Puppy Linux: /etc/X11/xkb/rules/base.xml
Ubuntu: /usr/share/X11/xkb/rules/evdev.xml

Open the file and search for the string '</layoutList>'. That is the closing 
tag of the list of layouts. We want to register our new layout file as the last 
layout file of the list. I added the following just above the </layoutList> 
line like here:

************* BEGIN LAYOUT DEFINITION IN base.xml or evdev.xml File 
*************
    <layout>
      <configItem>
        <name>romanized</name>
 
        <shortDescription>Singhala</shortDescription>
        <description>Singhala Dual-script</description>
        <languageList>
          <iso639Id>sin</iso639Id>
        </languageList>
      </configItem>
      <variantList/>
    </layout>   
  </layoutList>
************** END LAYOUT DEFINITION IN base.xml or evdev.xml File 
**************
(The last line is just for reference. Do not repeat the </layoutList> tag)


TAG ENCLOSURES
<name>romanized</name>: States the name of the layout file.

<shortDescription>Singhala</shortDescription>: I did not find any relation 
elsewhere to this

<description>Singhala Dual-script</description>: Name of variant found when 
setting up the keyboard.

<iso639Id>sin</iso639Id>: The registered name of a human language taken from 
www-01.sil.org/iso639-3/codes.asp. This has no programming consequence. It 
might as well be 'eng'. It has a dubious use in the future. A better way to 
determine the language of a body of text is to use heuristic pattern discovery 
such as comparing frequencies of letters and finding the existence of specific 
words.

<variantList/>: The ending '/>' says that it is an empty tag. That is, there 
are no variants to this layout.



*******************************************************
********** EDITING base.lst / evdev.lst FILE **********
*******************************************************

FILE LOCATION
Puppy Linux: /etc/X11/xkb/rules/base.lst
Ubuntu: /usr/share/X11/xkb/rules/evdev.lst

This file has four sections as follows:

! model: Physical keyboards
! layout: Name of layout file and its defaut keymap's 'name[Group1]' value
! variant: 'xkb_symbols' name of a variant, the name of the layout file and 
'name[Group1]' item. All three relating to a single layout file
! option: How various other keyboard actions are done such as switching between 
keymap layouts / variants.

My sample would be entered as the last item under '! layouts' section because 
it is a keymap in a file by itself:

********** sample entry in base.lst / evdev.lst file **********
  romanized       Singhala


REBOOT OR RESTART X11 and test.
If all is well, you'll be able to set your keyboard to switch between keymaps 
your favorite way. I selected Ctrl-Shift.



=================================================================================
=================================================================================



***********************************************************************
***********************************************************************
********** 2. HOW TO ADD A KEYMAP TO AN EXISTING LAYOUT FILE **********
***********************************************************************
***********************************************************************


*************************************
********** MAKE THE KEYMAP **********
*************************************

Make the keymap as above in tutorial 1, but delete the keyword 'default' from 
the first program line. In my case, now it would be like this:
partial alphanumeric_keys modifier_keys
xkb_symbols "singhala" {

Actually, I made slight changes to the top lines to come out like this:

********** sample top entries of a new keymap added to a layout file **********
partial alphanumeric_keys modifier_keys
xkb_symbols "singhala-DS" {
  name[Group1]= "Singhala Dual-script";
  include "us(basic)"
  include "level3(alt_switch)"



******************************************************
********** COPY KEYMAP INTO THE LAYOUT FILE **********
******************************************************

Copy that keymap to the layout file you want to associate it with. I added mine 
as the last variant of 'lk' country layout file as it is for romanized form of 
Singhala, the native language there.
/usr/share/X11/xkb/symbols/lk



****************************************************
********** EDIT base.xml / evdev.xml FILE **********
****************************************************

Register the layout variant by adding it to,
/etc/X11/xkb/rules/base.xml in Puppy
and
/usr/share/X11/xkb/rules/evdev.xml in Ubuntu

Mine was done this way:
Opened the XML file. Searched for the name of the layout file '>lk<'. Then 
searched for the tag, '</variantList>'. Pasted the block given below just above 
that tag. (That tag is shown here just to show you where it went to. Do not 
leave two lines with same </variantList> tag.

********** BEGIN BLOCK ADDED TO base.xml / evdev.xml FILE **********
        <variant>
          <configItem>
            <name>singhala-DS</name>
            
            <shortDescription>Singhala</shortDescription>
            <description>Singhala Dual-script</description>
            <languageList>
              <iso639Id>sin</iso639Id>
            </languageList>
          </configItem>
        </variant>
      </variantList>
*********** END BLOCK ADDED TO base.xml / evdev.xml FILE ***********



****************************************************
********** EDIT base.lst / evdev.lst FILE **********
****************************************************

FILE LOCATION
Puppy: /etc/X11/xkb/rules/base.lst
Ubuntu: /usr/share/X11/xkb/rules/evdev.lst

Added the following line next to those listed variants for the country layout 
file:
Searched for '! variant'. Then searched for 'lk:' in the second column. Then 
added the following line below them:

********** sample entry in the base.lst / evdev.lst file **********
  singhala-DS     lk: Singhala Dual-script 



***************************************************
********** RESTART AND HOPE FOR THE BEST **********
***************************************************

REBOOT or RESTART X11 and test.
Now set your keyboard to switch between keymaps your favorite way.

_______________________________________________
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s

Reply via email to