Turn a VIA-compatible RGB keyboard's backlight into a status lamp for Claude Code / Codex (raw HID, stock firmware)
Project description
kbd-signal
Turn a VIA-compatible RGB keyboard's backlight into a status lamp for AI coding agents on Windows and macOS (defaults target the Keychron K8 Pro). When Claude Code or Codex waits for your approval, your keyboard starts breathing orange — no need to watch the screen.
Works on stock firmware (no flashing) by speaking the VIA raw HID protocol directly.
Signals
| State | Trigger | Effect |
|---|---|---|
waiting |
Claude Code / Codex shows a permission dialog (PermissionRequest hook) |
Orange breathing |
done |
Main turn finished (Stop hook) |
Solid green for 5 s, then auto-restore |
error |
Manual kbd-signal set error |
Fast red breathing |
Before signaling, the current lighting (effect / speed / brightness / color) is snapshotted and restored afterwards. Nothing is ever written to EEPROM (RAM-only changes), so a power cycle always returns the keyboard to your saved settings.
Requirements & limitations
- Windows or macOS, Python 3.11+ (
hidapiis the only dependency; its macOS wheel is self-contained via IOKit, so no Homebrewhidapiis needed) - Keychron K8 Pro connected via USB cable with the rear switch set to "Cable". Raw HID is not available over Bluetooth — measured: in BT mode with the cable attached, the USB HID collections enumerate but the
0xFF60raw interface does not - When the keyboard is absent (BT mode, unplugged), the hook-facing commands (
hook,set,restore) silently no-op with exit 0 — hooks are never blocked. Diagnostic commands (detect,test,raw-effect) report the missing device and exit 1 - Do not run the VIA app / Keychron Launcher at the same time (concurrent raw HID writes race)
- Codex requires a version with lifecycle hooks; run
codex features listand confirm thathooksis enabled - Concurrent Claude Code / Codex sessions and subagents are tracked independently; orange remains active while any approval is pending
Platform support
| OS | Status | Hardware verification |
|---|---|---|
| Windows | ✅ Supported | Keychron K8 Pro (default), real hardware |
| macOS | ✅ Supported | Keychron Q1 HE 8K, real hardware¹ |
| Linux | 🧪 Best-effort | CI only — no hardware verification |
¹ The macOS raw-HID path (0xFF60 enumerate / open / protocol-probe, plus a Claude Code hook waiting → done → restore) is verified on a Q1 HE 8K. The default K8 Pro has not been round-tripped on macOS — the protocol layer is shared with the (verified) Windows path so it should work, but it is unconfirmed; a report either way is welcome.
Linux runs the same POSIX code path as macOS and is exercised in CI, but has no hardware verification. The PyPI classifiers list Windows and macOS only.
Install
Recommended: pipx — installs into an isolated environment and puts kbd-signal on PATH, which is exactly what the hook commands need:
pipx install kbd-signal
Windows — if you don't have pipx yet (one-time setup):
py -m pip install --user pipx
py -m pipx ensurepath # then open a new terminal
Plain pip also works (py -m pip install .); in that case invoke the hooks with the same interpreter you installed into: py -m kbd_signal hook claude.
macOS — install pipx with Homebrew if you don't have it (brew install pipx && pipx ensurepath), then pipx install kbd-signal. The hidapi wheel is self-contained (IOKit backend), so no brew install hidapi is required. Config, state, and log live in ~/Library/Application Support/kbd-signal/.
Usage
kbd-signal detect # find the keyboard, show protocol & current lighting
kbd-signal set <waiting|done|error>
kbd-signal restore [--after N] [--gen G]
kbd-signal test # play all patterns, then restore
kbd-signal raw-effect <n> # set a raw effect index (debug)
kbd-signal hook claude # entry point for Claude Code hooks (JSON on stdin)
kbd-signal hook codex [<json>] # Codex hooks (stdin) / legacy notify (argv)
Restore mode (config.json in the state dir)
The state dir is %LOCALAPPDATA%\kbd-signal on Windows and ~/Library/Application Support/kbd-signal on macOS.
{"restore": "off"}
"baseline"(default): restore the pre-signal effect and brightness"off": restore to brightness 0 (for people who normally keep the backlight dark). The stored effect/color/speed are still written back, so waking the backlight with Fn shows your own settings
The Fn backlight on/off flag is not readable over VIA, which is why "off" exists.
Claude Code integration
Register the same command for PermissionRequest, PostToolUse, Stop, and SessionEnd in your user-scope settings.json (events are dispatched internally by hook_event_name):
{"type": "command", "command": "kbd-signal hook claude", "timeout": 5}
(pipx install — the kbd-signal shim is on PATH. With a plain pip install, use py -m kbd_signal hook claude instead, matching the interpreter you installed into.)
Do not put a filesystem path in the program position. Hook commands may run through either cmd or a POSIX shell: backslashed paths get eaten as escapes by the POSIX shell, and forward-slashed program paths fail under cmd with "Access is denied" — both silently, so the hook simply never signals (measured on Windows 11). PATH-resolved names (kbd-signal, py -m kbd_signal) work under both. The entry point is cheap when idle (the hidapi DLL is imported lazily), so the same command is fine for hot hooks like PostToolUse.
That cmd-vs-POSIX hazard is Windows-only. On macOS/Linux an absolute path in the program position is safe, so if kbd-signal is not on the PATH your hooks run under, use its absolute path — pipx installs the shim at ~/.local/bin/kbd-signal.
Codex integration (since v0.3.0)
Use Codex lifecycle hooks. They are separate from the notify entry in ~/.codex/config.toml, so leave the existing notify command unchanged.
- Run
codex features listand confirm thathooksis enabled - Merge the events from examples/codex-hooks.json into the user-level
~/.codex/hooks.json; do not overwrite an existing file - Start the Codex CLI and choose
Review hooksfrom the startupHooks need reviewprompt, or open/hooks. Verify the source, event, and command before trusting them. Trust is tied to the hook definition hash, so review it again after any change - In a new session, trigger an approval and verify orange while waiting and restoration after approval
Every event uses the same command:
{
"type": "command",
"command": "kbd-signal hook codex",
"timeout": 5
}
The configuration uses:
PermissionRequestto add a pending approvalPostToolUseto release only the agent that completed its toolStopto release the main session and signal completion only when no other session is waitingSubagentStopto clean up a child without flashing green for the whole taskSessionStart/UserPromptSubmitto clean up stale entries for the same session after an interrupted run
Codex does not expose SessionEnd. If Codex is force-closed while an approval is pending and that session is never resumed, orange can remain active; run kbd-signal restore to recover.
The old agent-turn-complete notify payload remains supported for compatibility, but it cannot report approval waits and competes with the desktop app's notifier, so it is not recommended for new installations.
Concurrent sessions
Owners are keyed by product, session_id, and agent_id. A main-session completion therefore cannot clear another Claude/Codex session or one of its subagents. Updates to state.json remain serialized by the existing interprocess lock.
To roll back, remove only the entries whose command invokes kbd_signal hook codex from ~/.codex/hooks.json, then restart Codex. The desktop app's notify configuration remains untouched.
Protocol notes (verified on hardware)
- Shipped K8 Pro stock firmware speaks VIA protocol 9 (v2) — not the v3 custom-channel layout found on the
wireless_playgroundbranch. The protocol is probed at open time (command0x01) and both layouts are supported:- v2:
[report_id 0x00, cmd, value_id, data...], value ids0x80brightness /0x81effect /0x82speed /0x83color (hue, sat) - v3 (protocol ≥ 11):
[report_id 0x00, cmd, channel=3, value_id, data...], value ids 1–4
- v2:
- Commands: set
0x07, get0x08, save0x09(save is never used) - Effect indices are identical across firmware generations (
info.jsonanimation list matches): None=0, Solid Color=1, Breathing=2, … Solid Splash=22 - Device detection: VID
0x3434+ usage page0xFF60/ usage0x61(PIDs differ per layout variant)
Other keyboards (since v0.2.0)
The protocol layer is not K8 Pro specific: VIA v2 value ids are fixed by the VIA spec and Solid Color is always effect 1 in QMK. Point kbd-signal at another VIA-compatible RGB keyboard via config.json:
{
"restore": "off",
"device": {
"vendor_id": "0x3434",
"product_id": null,
"product_match": "K8",
"v3_channel": 3,
"effects": {"solid": 1, "breathing": 2}
}
}
Workflow for a new board:
kbd-signal detect --all— list every raw-HID (0xFF60) device and copy its VID/PID intoconfig.jsonkbd-signal raw-effect <n>— step through effect indices until you find solid/breathing, then seteffects- On a VIA v3 board, set
v3_channelto the keyboard'sid_qmk_rgb_matrixchannel from its VIA definition (v2 boards ignore it) kbd-signal test
Boards without RGB (single-color backlight) are out of scope — states are color-coded.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kbd_signal-1.0.0.tar.gz.
File metadata
- Download URL: kbd_signal-1.0.0.tar.gz
- Upload date:
- Size: 24.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f200d4ea92546f7a890b4049c905e7fa08b7110adada57c11a2fa72aa94de0f5
|
|
| MD5 |
ecce8b2a7fa55da1e5254d23639793ba
|
|
| BLAKE2b-256 |
999b2dc9da57063b56f7110c6c73cbb61e78a9f303f2f2086b8c02b2f43b2084
|
Provenance
The following attestation bundles were made for kbd_signal-1.0.0.tar.gz:
Publisher:
publish.yml on Sora-bluesky/kbd-signal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kbd_signal-1.0.0.tar.gz -
Subject digest:
f200d4ea92546f7a890b4049c905e7fa08b7110adada57c11a2fa72aa94de0f5 - Sigstore transparency entry: 2214799977
- Sigstore integration time:
-
Permalink:
Sora-bluesky/kbd-signal@f756cac0e62b239658b6425837143ef7160bbc66 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Sora-bluesky
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f756cac0e62b239658b6425837143ef7160bbc66 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kbd_signal-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kbd_signal-1.0.0-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f3661a7a29e7b23dc3af949a5cd0efef84b2cd7349ddfbe59f04534d53f0b51
|
|
| MD5 |
16a88e4a548a3cb8082721b88e5aa2e8
|
|
| BLAKE2b-256 |
fb554de2c4b9032beab497acc698e97d26a833d1170b5bd3076789cf3bfba0a3
|
Provenance
The following attestation bundles were made for kbd_signal-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Sora-bluesky/kbd-signal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kbd_signal-1.0.0-py3-none-any.whl -
Subject digest:
3f3661a7a29e7b23dc3af949a5cd0efef84b2cd7349ddfbe59f04534d53f0b51 - Sigstore transparency entry: 2214799983
- Sigstore integration time:
-
Permalink:
Sora-bluesky/kbd-signal@f756cac0e62b239658b6425837143ef7160bbc66 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Sora-bluesky
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f756cac0e62b239658b6425837143ef7160bbc66 -
Trigger Event:
release
-
Statement type: