-
Couldn't load subscription status.
- Fork 225
Description
Is your feature request related to a problem? Please describe.
This may be Mac-only. (it's the only system where I had any issues; didn't test any others)
Kanata should handle a situation where it can't connect to the output stream (e.g., driverkit HID daemon on Mac) more gracefully: either (1) don't grab any events from keyboards until the connection is established or (2) exit with error.
Currently, it keeps retrying to connect (on Mac at least), emitting connect_failed asio.system:61 on stdout, forever, while also not letting the physical keyboard events pass through. This creates a situation where the user can't type. That in turn can brick the system when kanata is used together with launchd (or equivalent) that keeps restarting it when we exit it via lctl+spc+esc.
Anecdote
I guess it's not too hard to read between the lines that it was me who managed to brick his system in this way. Overeager me had set up kanata to run from a launchdaemon with KeepAlive=true. I had an old Karabiner (full version) install that I had removed but that somehow still had a daemon running, so it wasn't immediately obvious that I needed to create a LaunchDaemon for the driverkit HID daemon myself (see also #1317 / updated driverkit instructions). And then on reboot it wasn't running anymore and the above happened.
Btw, if anyone else comes across this, you can quickfix this by either (1) booting into the recovery system, opening a terminal, mounting your data partition, and renaming your kanata plist file to *.bak or probably (2) just hitting lctl+spc+esc so often that launchd becomes tired of restarting kanata and then you can disable the launchdaemon from your regular system.
Describe the solution you'd like.
Kanata should either (1) not grab any events from keyboards until the connection is established or (2) exit with error in this situation.
Describe alternatives you've considered.
An easy workaround is to set KeepAlive=false in the kanata launchdaemon. Then you can just kill it with lctl+spc+esc and it doesn't come back, freeing up the physical keyboard.
I think this is a good idea independent of this issue b/c kanata doesn't usually crash "randomly" and when it does, we probably want to pause and investigate anyways. At least for users who don't have so strong accessibility needs that they need kanata to operate their computer.
Additional context
No response