The keyboard I am trying to create has a lot of Unicode and looks like this:
Being unsuccessful with the following tutorial:
- https://help.ubuntu.com/community/Howto%3A%20Custom%20keyboard%20layout%20definitions
(There are a few errors in the tutorial, and it uses imprecise language such as "Cutting" things instead of "Deleting" them, and it is formatted strangely)
I was wondering if anybody would be so kind to provide a better tutorial with step by step instructions?
In Ubuntu 14.04, keyboard layouts are kept in
/usr/share/X11/xkb/symbols/
Each of the files in this directory contains a series of entries of the following type:
This entry maps a key on the keyboard to a number of specific characters using the following conventions:
<A C01> The first letter
A
indicates we are looking in the alphanumeric key block (other options includeKP [for keypad]
andFK [for Function Key]
);<A C 01> The second letter
C
indicates the row, counting from the bottom in which the key is found. (In a standard US keyboard, the space bar is in rowAA
and the number keys are in rowAE
).<AC 01> The numbers
01
indicates the position of the key, counting from the left and ignoring any specially named key like TAB or ~ (tilde):AC01
is in the third row up, first key over from the left (ignoring Caps Lock, if present); on a standard US keyboard, this is the key marked “a”.The brackets enclose the list of characters assigned to each key. This contains up to four entries, separated by commas:
Creating a custom keyboard map is as easy as replacing the characters you don’t want in a given line with the ones you do!
For example:
As an Anglo-Saxonist, I type
á
andÁ
much less frequently than I typeæ
andÆ
.To add the Anglo-Saxon characters to my list, I simply replace
aacute
andAacute
with the entity names or Unicode code points foræ
andÆ
(“aelig” or U00E6 and “AElig” or U00C6, respectively):or
When I am finished modifying my keyboard layout, I save the file with a new name, "oe" in the same directory.
Adding a new keyboard layout to
evdev.xml
file.In order to use new keyboard layout, We need to tell
X11
that it exists. In Ubuntu 14.04X11
keeps track of installed keyboards in/usr/share/X11/xkb/rules/evdev.xml
file. Then lets add the new layout in it.X11/xkb/rules/evdev.xml
in an editorGo to the end of the
<layoutList>
section (search for</layoutList>
). Add the following after the last</layout>
tag, whereX
is the file name of your keyboard layout in/usr/share/X11/xkb/symbols
(in my caseoe
);Y
a suitable short name; andZ
an appropriate long name in one or more languages andaaa
a legal three letter (ISO 639-2) language code (e.g. eng for English):Here it is, follow complete introduction
Other related links:
http://ubuntuforums.org/showthread.php?t=188761&p=1092145#post1092145 http://www.charvolant.org/~doug/xkb/html/index.html
Note: Wayland does use xkb, but many xTools have stopped working properly (xdotool for example)
Note: This is a non-exhaustive tutorial. It is most useful for an individual looking to create a new eight level layout and understanding the syntax.
Note: A quick and dirty solution is provided. It includes a spreadsheet which automatically generates the code you need.
Understanding XKB Directory
Important if you want to customize the Modifier Keys.
Important if you are designing a non standard piece of keyboard hardware.
You will need to define this
Example: Macintosh Keyboards understand the spacebar as
57
. We write it however as<SPCE>
This is where we will define our custom layout.
Internal behaviour of Modifiers (Shift, Control, Alt...)
Workflow
keycodes > symbols > compat
I only touch
symbols
: See below for the Quick and Dirty solution.Symbol Maps
/symbols/us Any file in this directory follows the same structure.
partial - Not a complete keyboard map
alphanumeric_keys Section of the keyboard being mapped. Multiple can be used
Note: If no
*_keys
are specified, a complete keyboard is assumed."basic" - The name of the symbol map
name[Group1]= "US/ASCII"; Gives a unique name to this keyboard group.
modifier_map For editing modifier keys. (ctrl, shift, alt~)
Shift { Shift_L, Shift_R }; Not ordinarily neccessary. It maps both shifts to the shift modifier, aka level 2.
key <TLDE> The Tilde Key - Usually top left key right above Tab
key <AE01> Illustration - Composed of Three Parts, AE01
A = alphanumeric key block.
KP = Keypad
FK = Function Key
E = Row on Keyboard.
Space Key = A row
Shift Key = B row
Caps Lock = C row
Tab Key = D row
01 = Position of the key on the row.
AE01 = 1
AB02 = X
AC05 = G
[ + ] - In C Languages; Square brackets denotes a list, by which items are split by ,. The Length of the list determines the amount of levels. For example:
Typically, the Levels denote the following keypress with:
In short, if you wanted to map a key to shift + altgr, your list would have to be at least four items long.
WARNING - Common Errors
Either of these lines will cause a critical error, and will leave you without a usable keyboard:
Backspace
should beBackSpace
: Pay extra careful attention to spelling.VoidSymbol
.Best Safety Measure!
Backup your file that you are editting:
sudo /bin/cp /usr/share/X11/xkb/symbols/us /usr/share/X11/xkb/symbols/usBACKUP
Make a script that you can run without root password
Something like:
If anything goes wrong, use your mouse to run that line of code (contained in the bash script which you gave sudoers permission to. Remember to
chmod +x
to allow running as an executable.)Backup strategies to recover a broken system
return
(Pressing Enter) by pasting a linebreak.Quick and Dirty solution
(
!
becomesU0021
). Unicode supported!VoidSymbol
.sudo vim /usr/share/X11/xkb/symbols/us
Lines of interest: