Skip to content

Add configurable global hotkey (-hotkey flag + config)#23

Open
cemkocabasa wants to merge 1 commit into
sumerc:mainfrom
cemkocabasa:configurable-hotkey
Open

Add configurable global hotkey (-hotkey flag + config)#23
cemkocabasa wants to merge 1 commit into
sumerc:mainfrom
cemkocabasa:configurable-hotkey

Conversation

@cemkocabasa

Copy link
Copy Markdown
Contributor

Makes the global hotkey configurable instead of hardcoded Ctrl+Shift+Space. Addresses part 1 of #22.

What

  • -hotkey flag + config.json "hotkey" field — e.g. ctrl+shift+space, alt+space, cmd+shift+d, f8. Flag overrides config and is persisted; tokens are case-insensitive and order-independent.
  • Parser + validation in the golang.design/x/hotkey backend (hotkey_other.go, darwin/windows). Modifier aliases are per-OS (mods_darwin.go maps alt→Option, cmd→Command; mods_windows.go maps to Alt/Win); the key table is shared.
  • Graceful fallback — an empty or unparseable combo logs a warning and falls back to the built-in default, so a bad value never bricks the hotkey.
  • hotkey.New(combo) replaces hotkey.New(). Linux keeps its fixed evdev combo (accepts the arg for interface parity — remapping scancodes is out of scope here) and is noted as future work.
  • Tray labels — "Start/Stop Recording" now show the active combo instead of a hardcoded string.
  • doctor — the hotkey check registers and prints the configured combo.
  • Tests for parseCombo, Validate, and FormatCombo.

Design notes

Kept the codebase's "platform details behind build tags" philosophy: the modifier constants differ per OS (ModOption/ModCmd are darwin-only, ModAlt/ModWin windows-only), so only the alias tables are per-OS while parsing/formatting stay shared. No behavior change for existing users — the default is still ctrl+shift+space.

Testing

  • go build ./..., go vet, and go test ./... pass (unit).
  • Ran end-to-end via -test mode: -hotkey "alt+space" persists "hotkey": "alt+space" to config.json; -hotkey "bogus+combo" falls back to ctrl+shift+space with a warning.
  • I don't have the tray icon PNGs (they aren't committed to the repo, so go build ./... needs them present locally) — mention if you'd like me to adjust anything about how the tray label is wired.

A natural follow-up discussed in #22 is a tray submenu to pick the hotkey live; happy to send that separately if you'd like this mechanism first.

The global hotkey was hardcoded to Ctrl+Shift+Space. Make it configurable
via a -hotkey flag and a "hotkey" field in config.json (e.g. ctrl+shift+space,
alt+space, cmd+shift+d, f8).

- hotkey: add combo parser + Validate for the golang.design/x/hotkey backend
  (darwin/windows), with per-OS modifier alias tables and a shared key table
- hotkey: New(combo) replaces New(); empty/unparseable combos fall back to the
  built-in default. Linux keeps its fixed evdev combo (interface parity only)
- hotkey: FormatCombo() renders a stable human-readable label
- config: persist the chosen hotkey; -hotkey overrides config and is saved
- tray: record menu labels now reflect the active combo
- doctor: hotkey check uses and prints the configured combo
- tests for parseCombo/Validate/FormatCombo

Refs sumerc#22

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sumerc

sumerc commented Jul 9, 2026

Copy link
Copy Markdown
Owner

I would like to tweak this a bit to support changing hotkey from tray and/or settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants