Lahu Keyboard for Linux

The Lahu language uses various tone marks that are difficult to use with a standard keyboard layout.

The keyboards for Linux/Unix and Windows below will have the following mappings:

[ = (Unicode U+A788)
] = ˬ (Unicode U+02EC)
\ = ˍ (Unicode U+02CD)
{ = ˆ (Unicode U+02C6)
} = ˇ (Unicode U+02C7)
| = ˉ (Unicode U+02C9)

Hopefully the pattern should be clear. Note, to see the correct characters you will need to have a recent Unicode font installed.

There are two ways to install your own keyboard map in Linux, globally and per user (locally).

Local Custom Keyboard Map

Create your custom key map

Looking through the files under /usr/share/X/xkb/rules should give you an idea of how a keyboard map can be defined. You can either define an entire map (tedious and probably unnecessary) or simply inerit all the part you want and then adjust the bits you want changed. This is a method to create a Lahu keyboard. All we need to change are three keys which is six characters.

partial default alphanumeric_keys
xkb_symbols "basic" {

    // adds the Lahu tone characters to the basic keyboard

    include "latin"

    name[Group1]= "Lahu";

    key <AD11> { [ UA788,  U02C6,  bracketleft,   braceleft  ] };
    key <AD12> { [ U02EC,  U02C7,  bracketright,  braceright ] };
    key <BKSL> { [ U02CD,  U02C9,  backslash,     brokenbar  ] };

    include "level3(ralt_switch_multikey)"
};

Notice we declare this rule file as a ‘partial’ and the areas it will affect, ‘default’ and ‘alphanumeric_keys’. Further down we include the latin rule file which is essentially the default US keyboard mapping.

Next it is just a matter of defining the keys and their corresponding codes for normal keypress, shifted etc. We simply move the default to the 3rd and 4th level modified keystroke so that they were there if needed. These are accessed by the right ‘Alt’ key as indicated. Have a look at some other keyboard rule files to get a feel for it.

The codes we are interested in are UA788, U02EC, U02CD, U02C6, U02C7 & U02C9. To see the characters they correspond to see the page on Lahu.

Loading your keyboard rules

Here we use the setxbkmap and xkbcomp commands to load it into the current X session.

setxkbmap can set the keyboard and other options using provided rules files. Firstly we need to make sure it knows where to find things. In your home directory create a folder to hold things. Within this folder you need to create the subfolder ‘symbols’ which is where you place the rule file above. This is where xkbcomp will expect to find the rule file.

Then it is simply a matter of constructing the command to load and compile your rules file. An example is:

setxkbmap -I$HOME/.xkb -option grp:shifts_toggle,grp_led:scroll "us,th,lhu" -print | xkbcomp -I$HOME/.xkb - $DISPLAY

There are two parts to this, the first part sets the options for the X session by defining the two shift keys pressed together as the keyboard map toggle combination. It also sets the maps we wish to toggle between (US, Thai and our own Lahu). The output of this command is a short configuration that the keyboard compiler xkbcomp can read.

The second part of that command tells xkbcomp to load the configuration passed to it into the currently running X server. It will try to find the ‘lhu’ rule file in the folder structure created previously.

Load it on start up

Once this is tested and working it is easy enough to load this in your .xinitrc or .Xsession file before running your window manager. You should then be able to toggle your keyboard maps by using the two shift keys together with the scroll lock LED indicating the change.

Global (system wide) Instructions

‘lhu’ refers to the filename you created in step 1

<layout>
  <configItem>
    <name>lhu</name>
    <shortDescription>Lahu</shortDescription>
    <description>Lahu</description>
  </configItem>
</layout>

Note that the ‘name’ should be the same as the file created in step 1.

setxkbmap  -option grp:menu_toggle,grp_led:scroll "us,lhu"

The files used above can be found in the Github repository.