Skip to content

fix(linux): use DOM keyboard events for shortcut recording to avoid rdev::grab() conflict with HotkeyManager#1258

Open
possiblyneal wants to merge 1 commit intocjpais:mainfrom
possiblyneal:fix/linux-shortcut-recording
Open

fix(linux): use DOM keyboard events for shortcut recording to avoid rdev::grab() conflict with HotkeyManager#1258
possiblyneal wants to merge 1 commit intocjpais:mainfrom
possiblyneal:fix/linux-shortcut-recording

Conversation

@possiblyneal
Copy link
Copy Markdown

On Linux, rdev::grab() (used by the handy-keys backend recording loop) conflicts with the HotkeyManager — grabbing exclusive access to the keyboard causes periodic system freezes and no key events being captured during shortcut recording.

This PR fixes the issue by detecting Linux at runtime and falling back to DOM keydown/keyup events for shortcut recording instead of the backend handy-keys-event stream. The backend startHandyKeysRecording call is still made (so the backend can disable the active hotkey during recording), but key capture is handled entirely in the frontend on Linux.

Changes

src/components/settings/HandyKeysShortcutInput.tsx

  • Added a second useEffect that activates only on Linux (osType === "linux")
  • Builds the hotkey string from DOM KeyboardEvent modifiers + getKeyName()
  • Commits on keyup (same flow as the non-Linux path)
  • The existing handy-keys-event listener effect is still present but does not receive events on Linux since the backend skips the grab

src-tauri/src/shortcut/handy_keys.rs

  • Wrapped KeyboardListener::new() in #[cfg(not(target_os = "linux"))] so the second rdev::grab() call is never made on Linux, eliminating the periodic 2-second freeze

…dev::grab() conflict with HotkeyManager

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cjpais
Copy link
Copy Markdown
Owner

cjpais commented Apr 9, 2026

Is it possible to fix this directly in handy-keys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants