Add keymap-drawer workflow

I haven't tuned the output. For now this is just a demonstration of the
workflow.
This commit is contained in:
urob 2024-08-13 16:04:48 -04:00
parent c65ef715d9
commit 63222cc2dd
8 changed files with 32 additions and 3 deletions

4
.envrc
View file

@ -3,4 +3,6 @@ export DIRENV_LOG_FORMAT=$'\033[2mdirenv: %s\033[0m'
# Use flake
use flake
watch_file keymap_drawer.nix
# Watch additional files
watch_file draw/default.nix

3
.gitignore vendored
View file

@ -5,3 +5,6 @@
modules
firmware
zmk
# Ignore keymap-drawer output for now
draw/base.svg
draw/base.yaml

View file

@ -4,6 +4,7 @@ default:
config := absolute_path('config')
build := absolute_path('.build')
out := absolute_path('firmware')
draw := absolute_path('draw')
# parse combos.dtsi and adjust settings to not run out of slots
_parse_combos:
@ -75,6 +76,13 @@ clean:
clean-nix:
nix-collect-garbage --delete-old
# parse & plot keymap
draw:
#!/usr/bin/env bash
set -euo pipefail
keymap -c "{{ draw }}/config.yaml" parse -z "{{ config }}/base.keymap" >"{{ draw }}/base.yaml"
keymap -c "{{ draw }}/config.yaml" draw "{{ draw }}/base.yaml" -k "ferris/sweep" >"{{ draw }}/base.svg"
# initialize west
init:
west init -l config

8
draw/config.yaml Normal file
View file

@ -0,0 +1,8 @@
parse_config:
zmk_preamble: "#include <zmk-helpers/key-labels/34.h>"
zmk_additional_includes:
- "modules/helpers/include"
draw_config:
footer_text: "urob/zmk-config"
dark_mode: auto

View file

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Before After
Before After

View file

@ -19,7 +19,7 @@
devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
zephyr = zephyr-nix.packages.${system};
keymap_drawer = pkgs.python3Packages.callPackage ./keymap_drawer.nix { };
keymap_drawer = pkgs.python3Packages.callPackage ./draw { };
in {
default = pkgs.mkShell {

View file

@ -31,7 +31,7 @@ compatible with Zephyr 3.0 is available
- nix-based [local build environment](#local-development-workspace) -- simply
`cd` into your workspace and start building without any setup
![](img/keymap.png)
![](draw/keymap.png)
## Timeless homerow mods
@ -359,6 +359,14 @@ pristine build can be triggered with `just build all -p`.
(For this particular example, there is also a `just clean` recipe, which clears
the build cache. To list all available recipes, type `just`.)
#### Drawing the keymap
The build environment packages
[keymap-drawer](https://github.com/caksoylar/keymap-drawer). `just draw` parses
`base.keymap` and draws it to `draw/base.svg`. I haven't gotten around to
tweaking the output yet, so for now this is just a demonstration of how to set
things up.
#### Hacking the firmware
To make changes to the ZMK source or any of the modules, simply edit the files