Shajra Keyboards Save

Nix build/flash tool for a Keyboardio Model 100/01 or ZSA Technology Labs Ergodox EZ or Moonlander keyboard

Project README

img

About the project

This project has the “shajra” keyboard mappings for four ergonomic split keyboards:

Beyond the keymap, this project offers some streamlined automation with Nix that you can use for your own keymap. Or you can use this automation to return your keyboard to its factory default.

This automation only works for GNU/Linux (not MacOS or Windows). If you're new to Nix, this project bundles a few guides to get you started:

The rest of this document discusses using this automation. To get the most out of the keymap itself, you may be interested in the design document explaining the motivation behind the mapping.

The mappings

The “shajra” keymaps for all four keyboards are highly similar, which works out well because the physical layouts of these keyboards are also similar. We can more easily switch from one keyboard to another and retain the design benefits of the mapping.

Model 100 and Model 01 “shajra” keymap

img

Ergodox EZ “shajra” keymap (Moonlander similar)

img

Note the Moonlander keyboard is an almost identical layout to the EZ and not illustrated here. The Moonlander has only two fewer keys on the thumb cluster. This leads to not having either Home or End on the base layer for the Moonlander (they are still in a function layer). And the "application menu" keycodes are moved to the bottom-outer corners.

Using these key mappings

This project only supports a GNU/Linux operating system (sorry, not MacOS or Windows) with the Nix package manager installed.

QMK and Kaleidoscope have build complexities and dependencies that can take a moment to work through. Nix can automate this hassle away by downloading and setting up all the necessary third-party dependencies in a way that

  • is highly reproducible
  • won't conflict with your current system/configuration.

Using Nix, we won't have to worry about downloading QMK or Kaleidoscope, ensuring we have the correct versions of build tools like Arduino, without messing with Git submodules or setting up environment variables. Nix does all this for us. The provided scripts simplify using Nix even further.

The following steps will get your keyboard flashed.

1. Install Nix on your GNU/Linux distribution

If you don't have Nix installed and configured on your system, follow the instructions provided. As discussed, setting up Cachix and enabling the experimental flakes feature are both recommended.

2. Make sure your udev rules are set

To program either keyboard with a new mapping, you need to augment your OS configuration with new udev rules.

The following are recommended rules for each keyboard:

# For Ergodox EZ
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789A]?", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789ABCD]?", TAG+="uaccess"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789B]?", TAG+="uaccess"

# For Moonlander
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", \
    TAG+="uaccess", SYMLINK+="stm32_dfu"

# For Model 100
SUBSYSTEMS=="usb", ATTRS{idVendor}=="3496", ATTRS{idProduct}=="0005", \
    SYMLINK+="model100", ENV{ID_MM_DEVICE_IGNORE}:="1", \
    ENV{ID_MM_CANDIDATE}:="0", MODE="0666", TAG+="uaccess", TAG+="seat"

SUBSYSTEMS=="usb", ATTRS{idVendor}=="3496", ATTRS{idProduct}=="0006", \
    SYMLINK+="model100", ENV{ID_MM_DEVICE_IGNORE}:="1", \
    ENV{ID_MM_CANDIDATE}:="0", MODE="0666", TAG+="uaccess", TAG+="seat"

# For Model 01
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2300", \
    SYMLINK+="model01", ENV{ID_MM_DEVICE_IGNORE}:="1",   \
    ENV{ID_MM_CANDIDATE}:="0", MODE="0666", TAG+="uaccess", TAG+="seat"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="2301", \
    SYMLINK+="model01", ENV{ID_MM_DEVICE_IGNORE}:="1",   \
    ENV{ID_MM_CANDIDATE}:="0", MODE="0666", TAG+="uaccess", TAG+="seat"

These settings should roughly correspond to the official documentation of tools and libraries used by this project:

Note, if the MODE="0666" settings above are not set, you may require root-privileges (sudo) to call the flashing scripts.

Each distribution is different, but on many GNU/Linux systems, udev rules are put in a file in /etc/udev/rules.d with a ".rules" extension.

On some systems, you can activate these rules with the following commands:

udevadm control --reload-rules udevadm trigger

Or just restart the computer.

4. For Kaleidoscope, join the necessary OS group

NOTE: You don't need this step if you're flashing the Ergodox EZ or Moonlander.

Once udev is configured, when you plug in the Keyboardio Model 01, a serial device should appear under /dev/serial/by-id with a name matching "usb-Keyboardio_Model_01_*". This human-readable symlink pointing to the device should be something like /dev/ttyACM0. On many systems, this device is group-owned by the "dialout" or the "uucp" group:

In the following example, we can see the device is group-owned by the "dialout" group.

ls -lL /dev/serial/by-id/usb-Keyboardio_Model_01_*
crw-rw---- 1 root dialout 166, 0 Dec 28 20:09 /dev/serial/by-id/usb-Keyboardio_Model_01_Ckbio01E-if00

On most distributions, the following commands should work to join a group (substituting $TTY_GROUP and $USERNAME):

sudo usermod -a -G $TTY_GROUP $USERNAME
newgrp $TTY_GROUP

You should see memberships in the new group with the groups command:

groups | grep dialout
users wheel video dialout docker

5. Unplug and replug your keyboard

Unplug your keyboard and plug it back in to ensure everything's set to program. Rebooting your computer is probably overkill, but would probably work too.

6. Flash your keyboard

This project provides four scripts:

  • flash-ergodoxez
  • flash-model01
  • flash-model100
  • flash-moonlander

Calling these scripts without arguments will flash your respective keyboard with the "shajra" keymap. There is a "–factory" switch to flash your keyboard back to a factory default keymap.

If you enabled flakes in your Nix installation, you can run these scripts without installing them. Here's an invocation illustrating doing so with flash-ergodoxez:

nix run github:shajra/shajra-keyboards#flash-ergodoxez
Flashing ZSA Technology Lab's Ergodox EZ (custom "shajra" keymap)
=================================================================

FLASH SOURCE: /nix/store/6xkc1y2rmxc0rrs6k23q870iqw83qsby-qmk-builtin-shajra-src
FLASH BINARY: /nix/store/j825vrn8jsa0ssbcnsaivsw59zsqimbx-ergodoxez-builtin-shajra.hex

⠋ Press the reset button of your keyboard

The same works for the other three flashing scripts. Just replace "flash-ergodoxez" in the invocation above with the script of your choice.

Alternatively, the four flashing scripts are provided at the root of this project. Just clone this repository, and you can call them directly:

cd $SOME_WORKING_DIR
clone https://github.com/shajra/shajra-keyboards.git
cd shajra-keyboards
./flash-ergodoxez

Note that the first time you run the commands described below, you'll see Nix doing a lot of downloading and compiling. After that, subsequent invocations should be quicker with less output.

Flashing an Ergodox EZ keyboard

When flashing with flash-ergodoxez, you will be prompted to press a reset button. Access this button with an unbent paperclip inserted into the small hole in the top right corner of the right keyboard half.

Flashing a Moonlander keyboard

When flashing with flash-ergodoxez, you will be prompted to press a reset button. Access this button with an unbent paperclip inserted into the small hole in the top left corner of the left keyboard half.

Flashing a Keyboardio keyboard

When flashing with flash-model100 or flash-model01, you will be prompted with instructions to hold down the Prog key, and then press Enter.

The Prog key is hardwired to be the top-left-most key of the Keyboardio Model 01, but the Enter key can be remapped. If you forget where the Enter has been mapped to on your Keyboard, you can hit Enter on another connected keyboard.

Reverting to the factory default mapping

This project's scripts won't save off your previous keymap from your keyboard. But we can revert to the OEM keymap that your keyboard shipped with.

Reverting to the OEM keymap can be done with the -F / --factory switch, which all the flashing scripts support. If you forget your options, these scripts have a -h / --help switch.

Customization

Customizing keymaps

The provided code is relatively compact. In the keymaps directory, you should find familiar files you would edit in QMK or Kaleidoscope projects, respectively. These keymaps are compiled into the flashing scripts provided with this project.

For both keyboards, The “shajra” keymap is in its own directory. You can make your own keymaps and put them in a sibling directory with the name of your choice, and they'll be compiled in as well.

If you don't want to use keymaps compiled into the flashing scripts, you can use another directory of keymaps at runtime with the -K / -keymaps switch.

Then you can use the -k / --keymap switch to load your custom keymap by the name you chose for the keymap in the "keymaps" directory. The scripts should pick up changes, rebuild anything necessary, and flash your keyboard.

The used keymap source code is copied into /nix/store, and the invocation of the flashing scripts will print out a "FLASH SOURCE:" line indicating the source used for compiling/flashing for your reference. These are the whole source trees you'd typically use if following the QMK or Kaleidoscope documentation manually.

Development

This project relies heavily on Nix, primarily to help deal with all the complexity of setting up dependencies. The development of this project also relies on an experimental feature of Nix called flakes, not required to use the project. See the included introduction to Nix if you're new to Nix or flakes.

If you want to check that everything builds before flashing your keyboard, you can build locally everything built by this project's continuous integration:

tree $(nix build --no-link --print-out-paths) 2>/dev/null
/nix/store/8gklry1w8aqi978f7c24xfmig5gxpgjh-shajra-keyboards-ci
├── build-ergodoxez-builtin-shajra-flash -> /nix/store/zknvd1finyb7xnlkkbbzk1s6jsi0089j-ergodoxez-builtin-shajra-flash
├── build-ergodoxez-builtin-shajra-hex -> /nix/store/j825vrn8jsa0ssbcnsaivsw59zsqimbx-ergodoxez-builtin-shajra.hex
├── build-ergodoxez-factory-flash -> /nix/store/07isg4h2amca1ay3d8n6hxsxh3jc8bhg-ergodoxez-factory-flash
├── build-ergodoxez-factory-hex -> /nix/store/gdgxwckaah9yml7rih8yq4jbidgxsyr1-ergodoxez-factory.hex
├── build-model01-builtin-shajra-flash -> /nix/store/8ixkq6ijs05sk88a7g50324ffgrpq5f5-model01-builtin-shajra-flash
├── build-model01-builtin-shajra-hex -> /nix/store/w3n0xdgf12lvq6n5gspjgvxmyzzndmzs-model01-builtin-shajra-hex
├── build-model01-factory-flash -> /nix/store/ip0ibygwrlvf855h7g72p0fniyvps549-model01-factory-flash
├── build-model01-factory-hex -> /nix/store/ww8374v56q65rnbsyzfah2gmg1srjkj9-model01-factory-hex
├── build-model100-builtin-shajra-flash -> /nix/store/fpf1ni1l1wdcpr5kiy0xl2mwd93r6i7m-model100-builtin-shajra-flash
├── build-model100-builtin-shajra-hex -> /nix/store/sfaxa7ingh1n4vr61bcdm02sfzb4mpm1-model100-builtin-shajra-hex
├── build-model100-factory-flash -> /nix/store/kxb7jwsh2q9984mz419flyss8lxqlfsi-model100-factory-flash
├── build-model100-factory-hex -> /nix/store/x4a8jq3v0ickvzbpa08j1vrpni3afjim-model100-factory-hex
├── build-moonlander-builtin-shajra-flash -> /nix/store/yxvxsgdcwdx5zbaqpaimf7wlncm0ij9l-moonlander-builtin-shajra-flash
├── build-moonlander-builtin-shajra-hex -> /nix/store/fz876kyycdcj769lpxn5h4xw1nqzggg1-moonlander-builtin-shajra.bin
├── build-moonlander-factory-flash -> /nix/store/7hrc4k5vnvf1c5izspzbj4ispx0n2xf7-moonlander-factory-flash
├── build-moonlander-factory-hex -> /nix/store/1q0v81499ijh33cqpskq7fv923vs6ggn-moonlander-factory.bin
├── flash-ergodoxez -> /nix/store/ljpvh9ndkvqc8f78a3qbcqmj7gzhhkbn-flash-ergodoxez
├── flash-model01 -> /nix/store/69vrsyhdd2gzbvmpyw4xnr9y3k2sni6l-flash-model01
├── flash-model100 -> /nix/store/q9q8lqdb723d9vvqvqdk7p5r6nqd8861-flash-model100
├── flash-moonlander -> /nix/store/g61iqk3a76c40pnjli63iqgqbp704nly-flash-moonlander
└── licenses -> /nix/store/7vvyib9i1dd7n2lxvd8mbxgd680d6d9l-shajra-keyboards-licenses

18 directories, 4 files

Release

The "main" branch of the GitHub repository has the latest version of this code. There is currently no commitment to either forward or backward compatibility. However, the scripts for compiling/flashing are considered stable and less likely to change than the “shajra” keymap.

"user/shajra" branches are personal branches that may be force-pushed to. The "main" branch should not experience force-pushes and is recommended for general use.

License

This project is not a modified work in the traditional sense. It provides scripts the end user runs to make a modified work. Most of the source code modified (QMK, Kaleidoscope, and Model 01) is licensed under either GPLv2 or GPLv3.

If you have Nix installed, then a provided script licenses-thirdparty can be run to download all original source used, including license information.

In the spirit of the projects we build upon, all files in this "shajra-keyboards" project are licensed under the terms of GPLv3 or (at your option) any later version.

Please see the COPYING.md file for more details.

Contribution

Feel free to file issues and submit pull requests with GitHub. Ideas for how to improve automation are welcome. If you have ideas on how to improve the “shajra” keymap, just make a compelling argument considering the factors that have already gone into its design.

There is only one author to date, so the following copyright covers all files in this project:

Copyright © 2019 Sukant Hajra

Open Source Agenda is not affiliated with "Shajra Keyboards" Project. README Source: shajra/shajra-keyboards
Stars
33
Open Issues
0
Last Commit
2 weeks ago
License

Open Source Agenda Badge

Open Source Agenda Rating