Bug: device detection works poorly
Requirements
- [X] I've searched platform-specific issues, issues and discussions to see if this has been reported before.
Describe the bug
When I disconnect my external keyboard and reconnect it immediately (as in, less than one second later), the kanata service seems to stop working.
While this might seem contrived, I have a bad cable which keeps disconnecting and reconnecting when it moves. Having to restart the kanata systemd service to fix the issue is a bit annoying.
Relevant kanata config
I don't think this is very relevant, but:
keyboards.keychronK6 = {
devices = [ "/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd" ];
};
(defcfg
linux-dev /dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd
linux-continue-if-no-devs-found yes)
To Reproduce
- Connect external keyboard
- Pull the cable out and push it in super quickly
Expected behavior
Kanata should detect the device is still there.
Kanata version
1.4.0
Debug logs
2024-05-01T20:48:24.331828786+02:00 [INFO] kanata v1.4.0 starting
2024-05-01T20:48:24.33241852+02:00 [INFO] process unmapped keys: false
2024-05-01T20:48:24.332511135+02:00 [INFO] NOTE: kanata was compiled to never allow cmd
2024-05-01T20:48:24.332520932+02:00 [DEBUG] (1) kanata_parser::cfg::alloc: freeing allocations of length 0
2024-05-01T20:48:24.334953638+02:00 [INFO] config parsed
2024-05-01T20:48:24.335666745+02:00 [INFO] Created device "/dev/input/event10"
2024-05-01T20:48:24.335695751+02:00 [INFO] Created symlink "/run/keychronK6" -> "/dev/input/event10"
2024-05-01T20:48:24.335792071+02:00 [INFO] Sleeping for 2s. Please release all keys and don't press additional ones.
2024-05-01T20:48:26.33611098+02:00 [INFO] entering the processing loop
2024-05-01T20:48:26.336245193+02:00 [INFO] entering the event loop
2024-05-01T20:48:26.336335927+02:00 [INFO] registering /dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd: "Keychron Keychron K6"
2024-05-01T20:48:26.336354301+02:00 [INFO] Init: catching only releases and sending immediately
2024-05-01T20:48:26.921589974+02:00 [INFO] Starting kanata proper
2024-05-01T20:48:27.57772853+02:00 [WARN] removing kbd device: /dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd
2024-05-01T20:48:27.958465833+02:00 [INFO] watch found file changes, looking for new devices
2024-05-01T20:48:27.95847888+02:00 [INFO] checking for ["/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd"]
2024-05-01T20:48:28.060177572+02:00 [INFO] watch found file changes, looking for new devices
2024-05-01T20:48:28.060191286+02:00 [INFO] checking for ["/dev/input/by-id/usb-Keychron_Keychron_K6-event-kbd"]
Operating system
Nixos 23.11
Additional context
No response
As a first step you should upgrade to the most recent version of Kanata.
This area improved a lot in 1.5 iirc.
Come back and confirm.
Including the log from kanata --debug would make a lot of sense.
Maybe you need to adjust this value:
/// Milliseconds to wait before attempting to register a newly connected
/// device. The default is 200.
///
/// You may wish to increase this if you have a device that is failing
/// to register - the device may be taking too long to become ready.
#[cfg(target_os = "linux")]
#[arg(short, long, verbatim_doc_comment)]
wait_device_ms: Option<u64>,
Could try making it larger, or making it smaller.
Closing as stale