diff --git a/hypr/keybindings.lua b/hypr/keybindings.lua index b2288ca..7469d95 100644 --- a/hypr/keybindings.lua +++ b/hypr/keybindings.lua @@ -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)$" })) -- Copilot key (sends SUPER+SHIFT+F23): hold-to-talk voice dictation via whisrs --- press = start recording, release = stop and transcribe -hl.bind("SUPER + SHIFT + F23", hl.dsp.exec_cmd("whisrs toggle")) -hl.bind("SUPER + SHIFT + F23", hl.dsp.exec_cmd("whisrs toggle"), { release = true }) +-- press = start recording, release = stop and transcribe. The scripts check the +-- daemon state so stray toggles (key repeat, missed release) can't invert it. +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 }) diff --git a/hypr/scripts/whisrs-hold-start.sh b/hypr/scripts/whisrs-hold-start.sh new file mode 100755 index 0000000..bd54b4d --- /dev/null +++ b/hypr/scripts/whisrs-hold-start.sh @@ -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 \ No newline at end of file diff --git a/hypr/scripts/whisrs-hold-stop.sh b/hypr/scripts/whisrs-hold-stop.sh new file mode 100755 index 0000000..a2f491f --- /dev/null +++ b/hypr/scripts/whisrs-hold-stop.sh @@ -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 \ No newline at end of file