feat: add Insert key support + fix grab crash on hotplug#12
feat: add Insert key support + fix grab crash on hotplug#12cjpais merged 3 commits intohandy-computer:mainfrom
Conversation
Add Insert variant to Key enum with parser aliases ("insert", "ins"),
Display output, and platform keycode mappings for Linux (evdev) and
Windows (VK_INSERT). macOS is skipped as Mac keyboards lack Insert.
Closes handy-computer#11
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Point handy-keys at fork with Insert key support (handy-computer/handy-keys#12). Users can now bind actions to the Insert key. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Point handy-keys at fork with Insert key support (handy-computer/handy-keys#12). Users can now bind actions to the Insert key. Co-Authored-By: Claude Opus 4.6 <[email protected]>
rdev::grab() fails permanently on device hotplug (new keyboard plugged in, etc.) because it enumerates evdev devices once at grab time. Previously the listener thread would just exit, permanently killing all hotkeys until app restart. Now retries with 2s backoff, re-enumerating devices on each attempt. Respects the running flag to stop retrying on shutdown. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Thanks for this. One question, this hot-plug behavior with the issue, what happens exactly? And will this just keep erroring endlessly for two seconds, or will the next grab be expected to work? Looping every 2 seconds maybe isn't great if it's always going to throw every 2 seconds. But if it throws once, recovers and not throw again I think that is reasonable. I just don't know this path well enough. |
|
The next grab should be expected to work. Currently if I plug in just an extra keyboard or something, the rdev listener would just permanently unbind for both forever and I'd have to manually reset Handy to get it working again. We could make it just try again a limited number of times if you are worried about the loop but I think it's fine to cover more cases. |
|
Nah I think it's good, going to merge, thanks |
Adds Insert key support (Key enum, FromStr parser, Display, Linux/Windows keycode mappings) and fixes rdev::grab() dying permanently on keyboard hotplug by adding a retry loop.
Insert was the only navigation key missing from the Key enum. The grab retry fix prevents hotkeys from breaking when USB keyboards are plugged/unplugged — previously the listener thread would exit on any grab error with no recovery.
Note: the listener.rs diff is large (174 lines) but is mostly re-indentation from wrapping the existing callback + grab call in a retry
loop {}. The actual new logic is ~6 lines (match on grab error, sleep 2s, retry).