i guess follow me @bethposting on bsky or pillowfort


discord username:
bethposting

prophet
@prophet

I've been trying out the neo2 keyboard layout for a while now. I quite like it, but I'm still pretty slow, so it's going to take a while until I can use it as my default layout. Something I have been missing from neo though is the concept of Levels.

Your common run of the mill QWERTY layout only has two levels: nothing and shift. By contrast, neo has 6. Some of these just enable uncommon symbols, such as greek letters on levels 5 and 6, while others (mostly level 3) put characters like parentheses in positions that are easier to reach. But my personal favorite is level 4, which turns (QWERTY) S, D, F, E into arrow keys meaning you don't need to move your hand to move the cursor.

Now, it would be nice if one could use these without needing to switch to an entire new layout, don't you think? Well, the neo creators had the same thought, which is why neoQWERTZ1 (and neoQWERTY) exist.

The only problem: neoQWERTZ only keeps alphabetic QWERTZ characters, so if one wants to write, say ", one needs to use the neo bindings, rather than the QWERTZ ones, which kind of defeats the point of using neoQWERTZ in the first place.

What I want is a layout that keeps levels 1 and 2 from QWERTZ and uses the neo bindings for the other four. So, I made my own!

I'm on Linux using KDE, so no guarantuees about this working anywhere else.

The neo documentation has a nice section about defining custom layouts, that was quite handy (It's only available in German unfortunately, but Google Translate should work pretty well).

Keyboard layouts are located in /usr/share/X11/xkb/symbols/<countrycode>, using a slightly arcane definition language. While these use a bunch of macro-like systems to share definitions between layouts, these are too limited for what I want to define.

Key definitions are defined by declarations of the form

key <AC01> { a, A, backslash, Greek_alpha, Home, Home, U2200, NoSymbol ] };

While these are presumably nice to work with when writing out entire layouts by hand, these make it impossible to compose individual keyboard layers, since the entire key has to be written in one go.

But, if I could write a script to parse the neo and QWERTZ layouts, I could compose them myself!

/usr/share/X11/xkb/symbols/de defines quite a few different layouts and the definitions for individual keys are scattered across macros, which makes parsing a bit challenging. Fortunately, there is xkbcli compile-keymap, which compiles away all the macros for a layout into a single neat definition.

I then wrote a polaris script to 'parse' (read: perform horrible regex crimes on) the compiled definitions, which are then combined and assembled back into binding declarations.

I also added a few custom declarations (such as re-adding the QWERTY binding right-alt + Q for @).

And that's all it takes!

If you want to try it out yourself, you can find the assembled layout here.

I quite like it. In fact, I'm using it to write this post right now, which means I can easily insert γρεεκ λεττερσ :)


  1. QWERTZ is the German version of QWERTY. It's similar, except that Y and Z are swapped and most symbols are in different positions.


You must log in to comment.