Add configurable global hotkey (-hotkey flag + config)#23
Open
cemkocabasa wants to merge 1 commit into
Open
Conversation
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>
Owner
|
I would like to tweak this a bit to support changing hotkey from tray and/or settings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the global hotkey configurable instead of hardcoded
Ctrl+Shift+Space. Addresses part 1 of #22.What
-hotkeyflag +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.golang.design/x/hotkeybackend (hotkey_other.go, darwin/windows). Modifier aliases are per-OS (mods_darwin.gomapsalt→Option,cmd→Command;mods_windows.gomaps toAlt/Win); the key table is shared.hotkey.New(combo)replaceshotkey.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.parseCombo,Validate, andFormatCombo.Design notes
Kept the codebase's "platform details behind build tags" philosophy: the modifier constants differ per OS (
ModOption/ModCmdare darwin-only,ModAlt/ModWinwindows-only), so only the alias tables are per-OS while parsing/formatting stay shared. No behavior change for existing users — the default is stillctrl+shift+space.Testing
go build ./...,go vet, andgo test ./...pass (unit).-testmode:-hotkey "alt+space"persists"hotkey": "alt+space"toconfig.json;-hotkey "bogus+combo"falls back toctrl+shift+spacewith a warning.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.