hypr: guard whisrs hold-to-talk binds with daemon state

Long holds occasionally dropped the release event in Hyprland, leaving
whisrs recording until its silence auto-stop, and any stray toggle
(key repeat, re-fired press) could invert the state so that pressing
stopped and releasing started. The press and release binds now go
through tiny scripts that check the daemon status first, making the
toggle pair idempotent: start only when idle, stop only when recording.

Also a note-to-self: Hyprland auto-reloads when files under the config
symlink change, so a git rebase in this repo can transiently drop
newly added binds; run hyprctl reload after git operations.
This commit is contained in:
Jeena 2026-09-15 08:36:08 +09:00
parent 0651dd13ef
commit 7102e59dc5
3 changed files with 12 additions and 3 deletions

View file

@ -38,6 +38,7 @@ hl.bind("F1", hl.dsp.pass({ window = "class:^(com.obsproject.Studio)$" }))
hl.bind("F2", hl.dsp.pass({ window = "class:^(com.obsproject.Studio)$" })) hl.bind("F2", hl.dsp.pass({ window = "class:^(com.obsproject.Studio)$" }))
-- Copilot key (sends SUPER+SHIFT+F23): hold-to-talk voice dictation via whisrs -- Copilot key (sends SUPER+SHIFT+F23): hold-to-talk voice dictation via whisrs
-- press = start recording, release = stop and transcribe -- press = start recording, release = stop and transcribe. The scripts check the
hl.bind("SUPER + SHIFT + F23", hl.dsp.exec_cmd("whisrs toggle")) -- daemon state so stray toggles (key repeat, missed release) can't invert it.
hl.bind("SUPER + SHIFT + F23", hl.dsp.exec_cmd("whisrs toggle"), { release = true }) hl.bind("SUPER + SHIFT + F23", hl.dsp.exec_cmd("~/.config/hypr/scripts/whisrs-hold-start.sh"))
hl.bind("SUPER + SHIFT + F23", hl.dsp.exec_cmd("~/.config/hypr/scripts/whisrs-hold-stop.sh"), { release = true })

View file

@ -0,0 +1,4 @@
#!/bin/sh
# Start dictation only when the daemon is idle. Guards against stray toggle
# events (key repeat, re-fired press binds) inverting the recording state.
[ "$(whisrs status 2>/dev/null)" = "idle" ] && exec whisrs toggle

View file

@ -0,0 +1,4 @@
#!/bin/sh
# Stop dictation only when actually recording. If the release bind never
# fires, whisrs' own silence auto-stop (2s) ends the recording instead.
[ "$(whisrs status 2>/dev/null)" = "recording" ] && exec whisrs toggle