Skip to content

Add Keychron RGB handler to the theme keyboard pipeline - #9545

Open
reeseroyster wants to merge 5 commits into
omacom:quattrofrom
reeseroyster:keychron-rgb-sync
Open

reeseroyster wants to merge 5 commits into
omacom:quattrofrom
reeseroyster:keychron-rgb-sync

Conversation

@reeseroyster

Copy link
Copy Markdown

Summary

Adds Keychron RGB support to the existing keyboard.rgb theme pipeline, following the omarchy-theme-set-keyboard-asus-rog / -f16 handler pattern exactly.

Keychron's own firmware (V/Q/K "Ultra" and "Max" series, protocol v11+) implements the VIA raw-HID protocol on a vendor config channel (USB usage page 0xFF60, usage 0x61). It is the same lighting command set the Framework 16 handler already speaks via qmk_hid: solid effect ([7,3,2,1]), HSV color ([7,3,4,h,s]), NVRAM save ([9,3]). The protocol was extracted from Keychron's own Launcher web app (WebHID client) — no firmware flashing, no reverse-engineered vendor blobs.

Changes

  • bin/omarchy-keychron-rgb — transport: bash + embedded Python (stdlib only, no new packages, nothing to compile). Auto-discovers the config channel by vendor 3434 + usage-page signature and round-trip-probes it, so it works across models and connection modes (with cable and dongle both enumerated, one channel is a dead end depending on the keyboard's mode switch — the probe picks the live one).
  • bin/omarchy-hw-keychron — hardware detect (USB vendor 3434), hw-* pattern.
  • bin/omarchy-theme-set-keyboard-keychron — the handler; no-op without a Keychron present.
  • bin/omarchy-theme-set-keyboard — dispatch entry.
  • default/udev/keychron-rgb.rules + install/hardware/keychron-rgb.sh + migration — vendor-wide uaccess rule (also unblocks the official Keychron Launcher web app), mirroring framework/qmk-hid.sh.
  • install/hardware/all.sh — install wiring.

Verified behavior

Tested on a Keychron V1 Ultra 8K (ZMK-based, 3434:0c10) plus Ultra-Link 8K 2.4GHz dongle (3434:d028):

  • All 22 stock themes switched back-to-back; keyboard color read back over HID and matched the theme color byte-exact every time, including Tokyo Night's hand-picked keyboard.rgb (ff00ff) overriding the accent template.
  • User-created themes work automatically (accent template → staged keyboard.rgb).
  • Connection matrix: wired works; 2.4GHz dongle works (it tunnels the config channel; needs a radio-wake timeout, handled); Bluetooth intentionally holds the last synced color — the stock firmware exposes no config channel over BT (confirmed via the BT HID descriptor, the GATT service tree, and the Launcher client being WebHID/USB-only).
  • No-op cost on non-Keychron machines: one sysfs grep; the handler exits before spawning the transport.

Testing

  • ./test/cli — 116 ok, 0 failures (includes metadata lint for the new commands).
  • ./test/shell — 2905 ok, 0 failures.
  • End-to-end on real hardware as described above.

Transparency

This contribution was developed end-to-end with AI assistance (an agentic CLI coding assistant): protocol extraction from the Launcher bundle, tool implementation, and the automated 22-theme verification. The submitter performed all hardware verification on their machine.

One natural follow-up (not in this PR to keep it scoped): a udev RUN+ on the rule could invoke the handler on (re)plug, re-syncing the keyboard at boot and whenever it returns from wireless to wired. Happy to add if wanted.

@sprajs

sprajs commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

There is a migration-ID collision with #9478: both PRs add migrations/1788129995.sh, but that PR uses it to migrate Chromium notification flags and this one installs the Keychron udev rule. These are unrelated operations, so both need distinct completion markers.

Could one migration receive an unused timestamp before the PRs land? This avoids the add/add merge conflict and prevents either operation being lost when resolving it.

The same filename is also used by #9522 for nwg-displays workspace loading and #9562 for the XDG Desktop directory. Those four unrelated migrations need separate IDs.

1788129995.sh collides with six other open PRs (omacom#9276, omacom#9445, omacom#9446,
omacom#9478, omacom#9522, omacom#9562); same filename means the same completion marker,
so only the first merged migration would ever run. Renamed to the
fresh, currently-unused timestamp 1789739221.
@reeseroyster

Copy link
Copy Markdown
Author

Good catch — fixed in 0f80aad: the migration is now migrations/1789739221.sh (fresh timestamp at rename time; unused on quattro, across all open PRs, and in any existing branch or marker).

For what it's worth the collision was wider than the four PRs listed here: 1788129995.sh was also carried by #9276, #9445, and #9446 — seven open PRs shared the name. The completion-marker point stands either way; thanks for flagging.

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@josemiguelo

Copy link
Copy Markdown

Confirming the rule fixes the Keychron Launcher (launcher.keychron.com) on its own, as the rule's comment says: Keychron K15 Max over USB, Omarchy 4.0.4-1, Brave and Chrome.

Without it the Launcher sits at "connecting" forever with nothing in the browser console — the keyboard's hidraw nodes are root-only, so WebHID can't open them:

/dev/hidraw11 crw------- root:root   HID_ID=0003:00003434:00000AF0  usb-…-1/input0
/dev/hidraw12 crw------- root:root   HID_ID=0003:00003434:00000AF0  usb-…-1/input1
/dev/hidraw13 crw------- root:root   HID_ID=0003:00003434:00000AF0  usb-…-1/input2

Granting the user access to those nodes (sudo setfacl -m "u:${USER}:rw" /dev/hidraw1{1,2,3}, the ACL this rule's uaccess tag gives the active user) made the Launcher connect.

One thought: the rule is only installed when a Keychron is connected at install or migration time (omarchy-hw-keychron). Someone who plugs a Keychron in later never gets it, and the Launcher fails the same silent way. Since the rule matches vendor 3434 only, installing it unconditionally would be harmless on machines without one.

@reeseroyster

Copy link
Copy Markdown
Author

@josemiguelo Thanks for confirming the Launcher behavior. Fixed in 08a135b: the udev rule is now installed unconditionally during hardware setup, and a migration covers existing installs. Both reload udev and retrigger hidraw so already-connected Keychrons pick up the access rule too.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Adds udev rules and hardware control for keyboard RGB.

The PR appears safe to merge based on the changes since the previous review.

Summary

The PR adds Keychron RGB control to the theme keyboard pipeline, with USB detection, a raw-HID transport, a config-interface udev rule, installation and migration wiring, and tests.

  • Since the previous review, the RGB wrapper gained an installed-path fallback when OMARCHY_PATH is unset, and the tests gained checks for both path branches.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  T[Theme change] --> H[Keychron handler]
  H --> D{Keychron detected?}
  D -->|Yes| R[Read keyboard.rgb]
  R --> P[Python raw-HID transport]
  P --> K[Keyboard config interface]
Loading

Reviews (3) · Last reviewed commit: "Handle Keychron RGB calls without sessio..."

Comment thread bin/omarchy-theme-set-keyboard Resolved
Comment thread bin/omarchy-keychron-rgb Resolved
Comment thread default/udev/keychron-rgb.rules Resolved
Comment thread bin/omarchy-keychron-rgb Resolved
Comment thread bin/omarchy-theme-set-keyboard-keychron Resolved
@reeseroyster

Copy link
Copy Markdown
Author

Thanks for the review. Fixed in 790600f: the theme dispatcher now calls the correct handler; set/get preserve HSV brightness and failed saves return an error; the handler skips machines without Keychron hardware; and udev grants access only to hidraw interfaces with the config-channel report descriptor. The install/migration path installs the checker and replaces the exact shipped broad rule while preserving customized rules. Added focused coverage. Verified with test/shell.d/keychron-rgb-test.sh, ./test/cli, and udevadm verify default/udev/keychron-rgb.rules.

Comment thread bin/omarchy-keychron-rgb Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants