Skip to content
JiehoonKwakPublic

About

Use a Work Louder Codex Micro as a controller for the Rex terminal

Resources

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

rex-micro: a Codex Micro whose Agent Keys show the state of agent panes in Rex

rex-micro

Use a Work Louder Codex Micro as a controller for the Rex terminal. It doesn't need the Work Louder Input app or ChatGPT.

  • Agent Keys follow your agents. Each of the six keys tracks a pane running Claude Code, Codex or another agent, on this Mac or any Rex host it connects to, and shows its state in color. Press a key to jump to that agent's session and pane, or double-press to also zoom it.
  • Answer from the pad. APPROVE sends Enter and REJECT sends Escape to the focused pane. The stick moves focus between panes, and the dial scrolls.
  • Make every key yours. Bind any key, dial turn or stick direction to a Rex action, a key press, text, a rex command or a shell command. Add as many layers as you like and switch between them with the dial, or store up to six on the pad so its touch sensor switches them and its LEDs show the active one.
  • See what the keys do. Hold the dial and the active layer's keys appear on screen, shaped like the pad, without taking focus.

Demo: an agent asks for permission, its key turns amber, one press jumps there and APPROVE answers

Install

brew install JiehoonKwak/tap/rex-micro
rex-micro service install
rex-micro doctor

macOS asks once whether rex-micro may receive keystrokes. Allow it under System Settings → Privacy & Security → Input Monitoring. The pad sends its keys over a private HID channel, and macOS treats reading that channel as input monitoring.

macOS ties that permission to the executable's path and signature. The service runs a copy at ~/Library/Application Support/rex-micro/bin/ and refreshes it within 30 seconds of a brew upgrade, so you grant the permission only once. Releases are signed with the same self-signed certificate every time. A build you sign yourself, or an ad-hoc build, asks again after each change.

The Work Louder Input app and the ChatGPT desktop app also drive the pad, so quit Input. ChatGPT has no setting to let go of the pad, but it only talks to the pad while it has Input Monitoring: switch ChatGPT off under Input Monitoring and restart it. ChatGPT keeps working; you lose only its global dictation and modifier-only shortcuts such as Fn. rex-micro doctor warns while either app runs and reports when another app has changed the lights.

rex-micro only sees keys that still have their factory keycodes on the pad's first layer. If you remapped a key in Input, for example MIC to a dictation shortcut, that key keeps typing its shortcut, and rex-micro test lists it as handled by the device.

Requirements: macOS 13 or later, the Rex app, and a Codex Micro connected by USB-C or Bluetooth. rex-micro runs the rex CLI of the Rex server that is running, so it always matches the server's version, even right after a Rex update; REX_MICRO_REX=/path/to/rex overrides that.

Without Homebrew
git clone https://github.com/JiehoonKwak/rex-micro && cd rex-micro
go build -o ~/.local/bin/rex-micro ./cmd/rex-micro
rex-micro service install      # starts at login via launchd
Verify a download

Releases are immutable and carry a build attestation. Check that a tarball was built by the release workflow from its tag, and that it belongs to that release:

gh attestation verify rex-micro_X.Y.Z_darwin_universal.tar.gz -R JiehoonKwak/rex-micro \
  --signer-workflow JiehoonKwak/rex-micro/.github/workflows/release.yml \
  --source-ref refs/tags/vX.Y.Z
gh release verify-asset vX.Y.Z rex-micro_X.Y.Z_darwin_universal.tar.gz -R JiehoonKwak/rex-micro

Default layout

Control Action
Agent Keys Jump to that agent's pane. Double-press to also zoom it.
FAST Zoom the focused pane
APPROVE / REJECT Send Enter / Escape
SPLIT Split the focused pane
CODEX Send Enter
MIC Unbound by default; bind your dictation tool here
Stick Move focus up, down, left or right
Dial Turn to scroll (Page Up / Page Down); press to open Rex's Activity; hold to show the keys

Agent Key colors:

Color State
Blue, breathing working
Amber, breathing waiting for you (permission or question)
Red, breathing error
Green done
Dim white idle
Off no agent assigned

A blocked agent may say what it waits for (permission, question or auth); blocked_permission = { ... } and the like under [lighting.states] give that kind its own look.

Configuration

rex-micro edit           # full-screen editor: press a control on the pad to pick it
rex-micro config init    # or write ~/.config/rex-micro/config.toml yourself
rex-micro keys           # what every key does, per layer

rex-micro edit shows the pad. Press a key, turn the dial or push the stick to select that control, then choose what each gesture does from a searchable list of Rex actions, key presses, shortcuts, text and commands. The layer menu (l) adds, renames, colors and deletes layers and sets when a layer turns on by itself. The editor changes only the lines it must, so your comments stay.

The daemon reloads the file when you save it. The default config documents every setting and ends with example layers to uncomment: sessions and tabs, a browser layer, and Copy Mode on the stick and dial. Here is a second layer for tools and a push-to-talk MIC key:

[[layer]]
name = "agents"
color = "#8B5CF6"

[layer.keys]
# A dictation app on a modifier hotkey: hold it as long as MIC is held, so the
# app tells a tap (toggle) from a hold (push-to-talk) itself.
MIC = { shortcut = "right_option", held = true }
# One with start/stop URLs instead:
# MIC = { down = { shell = "open -g 'myapp://dictation/start'" }, up = { shell = "open -g 'myapp://dictation/stop'" } }

[[layer]]
name = "tools"
color = "#06B6D4"

[layer.keys]
ACT06 = { rex = ["run", "--", "lazygit"] }
ACT07 = { action = "pane.split.right" }
ACT08 = { key = "ctrl+c", target = "agent" }
AG00  = { builtin = "session.1" }

[[layer]]
name = "browser"
color = "#22C55E"
match = { app = "Google Chrome" }   # on whenever Chrome is in front

[layer.keys]
ENC_CW = { shortcut = "cmd+shift+]" }   # next tab
ENC_CC = { shortcut = "cmd+shift+[" }   # previous tab

A binding is one of: a Rex action, key presses to a pane or agent, a keyboard shortcut (a lone modifier works as a dictation hotkey), text, rex CLI arguments, a shell command, or a builtin such as layer.next. A key can also take one binding per gesture (press, double, hold, down, up). A layer can turn on by itself for the app in front or the program in the Rex pane you see, and the Agent Keys follow agent panes (in a fixed order or the Rex sidebar's Activity order), sessions or named slots. The default config shows every option with an example; rex-micro config default prints it.

A shell binding learns the key, the layer and the selected agent's pane through REX_MICRO_* variables. Recipes use them to open the dev server an agent started, on any host, or to approve only a permission prompt.

Shortcut bindings need Accessibility: the daemon asks for it the first time your config uses one, and rex-micro doctor checks it.

Seeing the keys

{ builtin = "keys.show" } puts the active layer's keys on screen, laid out like the pad, over every app and without taking focus. On a hold (the default dial hold) they stay while the key is held; on a press, for five seconds or until the next pad input. Give a binding label = "..." to name it there and in the editor:

ACT06 = { shortcut = "cmd+shift+z", label = "Focus mode" }

An Agent Key shows its agent's session, app and latest status message, the line Rex's Activity shows for it.

Layers on the pad

The pad has layers of its own: the touch sensor at its bottom left cycles them, and three LEDs show which is on. Set

[pad]
layers = "sync"

and rex-micro stores one pad layer per [[layer]] (at most six). The touch sensor then switches rex-micro's layers, and a layer that turns on by match or the dial shows on the LEDs, so the dial press is free for something else. The keymap this replaces (what Work Louder Input wrote) is saved and written back when you set layers = "off"; do that before uninstalling. Quit Work Louder Input while sync is on, since it rewrites the pad's keymap.

A layout that keeps Rex in charge: leave the Agent Keys on agents in every layer ([agents] always = true), let layers turn on by program (lazygit, a diff tool) or app (a browser), and keep a hand-picked layer for things like moving between sessions and splits.

For agents

rex-micro ships an agent skill that teaches coding agents to edit this config safely:

rex-micro skill install            # ~/.claude/skills/rex-micro/SKILL.md
rex-micro skill install ~/.codex/skills

Then ask your agent something like "make the dial switch Rex tabs on a second layer".

Commands

Command Purpose
rex-micro edit Edit bindings and layers on screen
rex-micro doctor Check Rex, the pad, permissions, the config and conflicting apps
rex-micro status Show the pad connection, the active layer and the pane each Agent Key follows
rex-micro press KEY Handle a key as if pressed on the pad (--double, --hold), to try a binding without the pad
rex-micro test Guided hardware check: press each key and confirm the lights (--lights for the lights only)
rex-micro monitor Print raw pad events
rex-micro lights demo Play the Agent Key colors (useful for recordings)

Logs: ~/Library/Logs/rex-micro.log.

How it works

The pad's keys don't send ordinary keystrokes. Every key, the dial and the stick report over a vendor HID channel (usage page 0xFF00) as JSON-RPC, and the same channel drives the LEDs. rex-micro opens that channel with IOKit. It follows Rex through one long-running rex do script that rebuilds a snapshot of every pane's agent state inside the server when Rex reports a change (and every [rex] poll in case one was missed), and sends key actions back through the rex CLI. Protocol facts come from FreeMicro's reverse-engineered PROTOCOL.md and from measurements on firmware 0.6.2: device.status reports the pad's layer (layer_index, counted from 1), fs.read/fs.writebin read and replace its keymap.json, and host.focused_app switches to the layer linked to an app. Pad layers rely on these.

License

MIT. Not affiliated with Work Louder, OpenAI or Rex.

About

Use a Work Louder Codex Micro as a controller for the Rex terminal

Resources

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages