Skip to content

Commit

Permalink
Add keymap-drawer workflow
Browse files Browse the repository at this point in the history
I haven't tuned the output. For now this is just a demonstration of the
workflow.
  • Loading branch information
urob committed Aug 13, 2024
1 parent c65ef71 commit 63222cc
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
modules
firmware
zmk
# Ignore keymap-drawer output for now
draw/base.svg
draw/base.yaml
8 changes: 8 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions draw/config.yaml
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 63222cc

Please sign in to comment.