fix(hotkey): exit listener cleanly when event channel is dropped

The evdev listener's run loop did `let _ = event_tx.send(event).await`
inside the trigger-key match arm. If the receiver was dropped without
the explicit shutdown signal (set hotkey to None), the send returned
Err and the loop kept polling — sending into a closed channel forever
until something else terminated the task.

Replace with explicit handling: on Err, log via log::warn! once and
return Ok(()) from `run`. The shutdown-via-None path is unaffected.
kon-hotkey still 4/4.

https://claude.ai/code/session_0189xUb6ie6t9qHkzatGZ9Rb
This commit is contained in:
Claude
2026-04-25 09:38:03 +00:00
parent a7fdc96e7b
commit d5d751c9ad

View File

@@ -317,10 +317,26 @@ async fn device_listener(
&& alt_held == combo.alt
&& super_held == combo.super_key
{
if pressed {
let _ = event_tx.send(HotkeyEvent::Pressed).await;
let to_send = if pressed {
Some(HotkeyEvent::Pressed)
} else if released {
let _ = event_tx.send(HotkeyEvent::Released).await;
Some(HotkeyEvent::Released)
} else {
None
};
if let Some(event) = to_send {
if event_tx.send(event).await.is_err() {
// Receiver was dropped without an
// explicit None-on-hotkey-rx
// shutdown. Log once and exit so
// the listener doesn't spin
// sending into a closed channel.
log::warn!(
"Hotkey event channel closed; \
listener for device exiting"
);
return Ok(());
}
}
}
}