# Layout generation using XKB

**URL:** <https://community.keyboard.io/t/layout-generation-using-xkb/234>\
**Category:** Model 01 Layouts\
**Created:** [December 15, 2016, 7:31pm UTC](https://community.keyboard.io/t/layout-generation-using-xkb/234 "2016-12-15T19:31:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewg](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/andrewg/32/43_2.png) [@andrewg](https://community.keyboard.io/u/andrewg)\
**Post date:** [December 15, 2016, 7:31pm UTC](https://community.keyboard.io/t/layout-generation-using-xkb/234/1 "2016-12-15T19:31:09Z")

</div>

I got a little tired of editing the keyboard layouts, and thought it would be better to do it programmatically. Linux’s XKB system has a slightly clunky but programmable tool to generate PDFs of whatever combination of keyboard layout and keymap you want (this is what normally comes up when you choose “keyboard viewer” in the settings).

I found a kinesis layout description and updated it to approximate the Model01. It isn’t as pretty as Jesse’s SVGs, or even the keyboard editor. But it does have the advantage that I can run off a batch of keyboard layouts with one bash script.

The source files are on github for your enjoyment (caveat: still very much a work in progress) [https://github.com/andrewgdotcom/keyboardio-xkb](https://github.com/andrewgdotcom/keyboardio-xkb)

And here is some sample output for the default layout using Linux US\_ASCII (should be the same on other OSes):

 ![](https://canada1.discourse-cdn.com/flex031/uploads/keyboard/original/1X/265eecefa71cdf4e31a2335562fa47caf738f510.png)

(EDIT: I just noticed I have the modifiers ordered the way I like them, rather than the default. Fixed in the source.)

Note for non-linux people: Super=Windows and Meta=Alt. I think it came up that way due to the order in which aliases are defined in XKB. Note also that the wheel like symbol is apparently a symbol for Control (who knew?). I enabled this (also the symbols for Escape etc.) because the text “Control\_L” spilled over the edges of the keys.

---

<div class="post-metadata">

**Author:** ![fishheadsoup](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/fishheadsoup/32/161_2.png) [@fishheadsoup](https://community.keyboard.io/u/fishheadsoup)\
**Post date:** [December 15, 2016, 8:45pm UTC](https://community.keyboard.io/t/layout-generation-using-xkb/234/2 "2016-12-15T20:45:45Z")

</div>

XKB sounds like a Soviet era Spec Ops team… now doing IT work.

---

<div class="post-metadata">

**Author:** ![andrewg](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/andrewg/32/43_2.png) [@andrewg](https://community.keyboard.io/u/andrewg)\
**Post date:** [December 16, 2016, 11:37am UTC](https://community.keyboard.io/t/layout-generation-using-xkb/234/3 "2016-12-16T11:37:14Z")

</div>

XKGB - Russian black ops keyboard layout  
XKCB - Sysadmin keyboard layout  
KKKB - Internet troll keyboard layout

😛

---

<div class="post-metadata">

**Author:** ![antevens](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/antevens/32/190_2.png) [@antevens](https://community.keyboard.io/u/antevens)\
**Post date:** [December 16, 2016, 12:25pm UTC](https://community.keyboard.io/t/layout-generation-using-xkb/234/4 "2016-12-16T12:25:53Z")

</div>

I prefer XKCD and XFCE

---

<div class="post-metadata">

**Author:** ![andrewg](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.keyboard.io/andrewg/32/43_2.png) [@andrewg](https://community.keyboard.io/u/andrewg)\
**Post date:** [December 16, 2016, 9:52pm UTC](https://community.keyboard.io/t/layout-generation-using-xkb/234/5 "2016-12-16T21:52:52Z")

</div>

I’ve now updated the scripts to use ultra-simple config files for generating printable layouts. The default config file is this:

```
LR0="PROG AE01 AE02 AE03 AE04 AE05 LED" # number row, left hand
LR1="TLDE AD01 AD02 AD03 AD04 AD05 TAB" # 
LR2="PGUP AC01 AC02 AC03 AC04 AC05 ESC" # home row, left hand
LR3="PGDN AB01 AB02 AB03 AB04 AB05"	#

LTH="LCTL BKSP LWIN LFSH" # thumb keys, left hand
LPA="FN" # palm key, left hand

RR0="ANY AE06 AE07 AE08 AE09 AE10 NUM" # number row, right hand
RR1="RTRN AD06 AD07 AD08 AD09 AD10 AE11" # 
RR2="BFLY AC06 AC07 AC08 AC09 AC10 AC11" # home row, right hand
RR3=" AB06 AB07 AB08 AB09 AB10 AE12" #
                                     
RTH="RTSH RALT SPCE RCTL" # thumb keys, right hand
RPA="FN" # palm key, right hand

```

That’s it! Just a list of the keys in a sensible order. (The names used are X’s internal representation of the keys - I’ve provided a file containing an annotated list of them)

I have broken out a template file containing the above vector graphic outline and the placement of the internal scancodes (R0C0 etc), which is independent of firmware configuration. From this template, the layout config files as above, and X’s standard keymap library, we can produce layout diagrams showing how the keyboardio will behave under each combination of firmware and software key mappings.

TODO: handle multiple layers efficiently. Currently you have to define a separate config file for each layer…
