Skip to content

Latest commit

 

History

History
292 lines (191 loc) · 17.2 KB

README.md

File metadata and controls

292 lines (191 loc) · 17.2 KB

img

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/jh8amnmmz0l144sjxhgvn7i5kmfc6671-qmk-builtin-shajra-src
FLASH BINARY: /nix/store/5ab4pw23lb691s6snkawgfxh6idx5wzf-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/k9xvsycfi78r7sld054cg6n72d2dc1i8-shajra-keyboards-ci
├── build-ergodoxez-builtin-shajra-flash -> /nix/store/sk0qj7k0cibag98gsn3sfdd1x188d5b7-ergodoxez-builtin-shajra-flash
├── build-ergodoxez-builtin-shajra-hex -> /nix/store/5ab4pw23lb691s6snkawgfxh6idx5wzf-ergodoxez-builtin-shajra.hex
├── build-ergodoxez-factory-flash -> /nix/store/xgsj221cxppsg7pa0rdm08iiwqv14c3v-ergodoxez-factory-flash
├── build-ergodoxez-factory-hex -> /nix/store/cwd1ksbknjvc0nq6d29jkrsms86nfpqr-ergodoxez-factory.hex
├── build-model01-builtin-shajra-flash -> /nix/store/92mdwd12v03azygy6x0k3k99xcil5idq-model01-builtin-shajra-flash
├── build-model01-builtin-shajra-hex -> /nix/store/kvik2b3r96d3g3sfxzl2fppkq6afin7f-model01-builtin-shajra-hex
├── build-model01-factory-flash -> /nix/store/8h7idnxnk6lqxfdk599iggfz8a47k7hn-model01-factory-flash
├── build-model01-factory-hex -> /nix/store/pb8ivna4nbdhzpf4xss0j3hfvay8qfcj-model01-factory-hex
├── build-model100-builtin-shajra-flash -> /nix/store/s7i74bc9h6qk0i5x7q5sslqbsprpyhy0-model100-builtin-shajra-flash
├── build-model100-builtin-shajra-hex -> /nix/store/c67gyphcghhqv2hhbnvwl5fvjdwavrys-model100-builtin-shajra-hex
├── build-model100-factory-flash -> /nix/store/l7nwf0afsw6z2k06w13pnzldaazvag4z-model100-factory-flash
├── build-model100-factory-hex -> /nix/store/lfgm06rj71hq5brfljyw845a5gpxjfn1-model100-factory-hex
├── build-moonlander-builtin-shajra-flash -> /nix/store/zxycnxpzzpbx5dbbkpdq1fgywd552vk8-moonlander-builtin-shajra-flash
├── build-moonlander-builtin-shajra-hex -> /nix/store/k93d4an9bc6pnb2lhypazkmig7hbjdxg-moonlander-builtin-shajra.bin
├── build-moonlander-factory-flash -> /nix/store/4byywkmxx3qjm6s41wfhbqmjqcxvin4r-moonlander-factory-flash
├── build-moonlander-factory-hex -> /nix/store/18zykf6ngak6wy128cng3ryy371p9ksa-moonlander-factory.bin
├── flash-ergodoxez -> /nix/store/5y23f63f34bix7s5xx2z81cm6wy06zdc-flash-ergodoxez
├── flash-model01 -> /nix/store/h023yg6nx832f3pzn99gqp3i12x51vi4-flash-model01
├── flash-model100 -> /nix/store/cn65ivb44dqix87h6j822x8w41lgyq96-flash-model100
├── flash-moonlander -> /nix/store/vnb7jz97ipc6hj3zx6lmdnfkilcfz301-flash-moonlander
└── licenses -> /nix/store/lqwjdfl0889ywzm74aqkxr67kfli45mp-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