Add Keymap Cheat Sheet: a bar cheat sheet drawn from a keymap repo

Reads keymap-drawer YAML (or a ZMK .keymap / QMK keymap.json) from a git
repo, default xnmrph/corne. Watches it with git ls-remote and redraws when
the keymap changes; waits for the repo's CI redraw after a .keymap push.
Overview puts four layers in the key corners; each layer also has its own
tab; combos and conditional layers are listed underneath.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-11-29 14:50:31 +01:00
1 parent 1f2dc91559
commit 9efb66fe5e
8 files changed
+1971

No files matched your search

+73
View File
@@ -0,0 +1,73 @@
# Keymap Cheat Sheet
A keyboard button in the bar that opens a cheat sheet of your keyboard's layers,
drawn from the keymap in a git repository (default: `xnmrph/corne`). Push a
change to the keymap and the sheet redraws by itself; the bar icon lights up
until you look at it.
- **Overview** shows the base layer in the middle of each key and four more
layers in its corners, each in its own colour (the little key in each tab
shows which corner). The colours follow the theme accent.
- **A layer tab** shows that layer on its own. Keys that fall through to the
base layer are dimmed, the key you are holding to get there says *held*, and
keys that switch layers take that layer's colour. Pointing at a tab
previews it.
- **Combos** for the layer on screen are listed underneath; pointing at one
lights up its keys. Layers you reach by holding two layers (ZMK conditional
layers) are listed too.
Keys while it is open: arrow keys / Tab (or H/L) switch layers, `0` is the
overview, `1`–`9` pick a layer, `R` checks the repo now, Esc closes.
Right-clicking the bar icon also checks the repo.
## Where the keymap comes from
Settings (Settings → Bar → Keymap):
| Setting | |
| --- | --- |
| Keymap repository | `owner/name` on GitHub, or any git URL / local path. Private repos use your git credentials. |
| Branch | Blank: the default branch. |
| Keymap file | Blank: found automatically. |
| Check for changes every | Minutes between checks (default 2). It also checks when you open the sheet. |
| Opens on | Overview or the base layer. |
The file is found in this order:
1. **keymap-drawer YAML** (`keymap parse` output). With several, the one with
the most layers wins, so `corne-layers.yaml` beats the merged `corne.yaml`.
Its legends are already pretty, so this is the best source.
2. **ZMK `.keymap`**, parsed directly (`&kp`, `&mo`, `&lt`, `&mt`, `&bt`,
mouse keys, combos, conditional layers; other behaviours show their name).
3. **QMK `keymap.json`**.
The physical layout is drawn from the key count: 42 and 36 keys as a Corne
(3×6+3 / 3×5+3), 34 and 40 as split boards with two thumb keys; anything else
as a plain grid.
## How it watches the repo
A check is a `git ls-remote` (no GitHub API, so no rate limit). Only a new
commit fetches: the repo is kept as a shallow clone in
`~/.cache/glassMxrph/keymap/`, together with the last parsed sheet, so the
sheet shows at once after a restart and while offline.
When the newest commit changed the `.keymap` but not the keymap-drawer YAML,
and a workflow in the repo redraws it (like `xnmrph/corne`'s `draw.yml`), the
sheet says it is waiting for the redraw and checks every 20 seconds until the
new YAML lands.
## IPC
```sh
quickshell ipc --path <shell> call keymap toggle
quickshell ipc --path <shell> call keymap layer Symbols # open on a layer ("overview" too)
quickshell ipc --path <shell> call keymap refresh
quickshell ipc --path <shell> call keymap status
```
With glassMxrph: `glassmxrph plugin toggle mx-keymap`.
## Tests
`python3 tests/keymap_test.py`