From 9137bd2d80a85d185769f9e0182f4030b9ccb62e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Mar 2026 20:33:03 +0000 Subject: [PATCH] Fix stop toggle not reaching OpenWhispr on key release Add --clearmodifiers to xdotool so held Ctrl/Alt don't corrupt the simulated Ctrl+` into Ctrl+Alt+`. Also add 50ms delay before stop to let key release propagate to X11. https://claude.ai/code/session_01XKYC1basxdwtHy71tky7xm --- openwhispr-ptt.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openwhispr-ptt.py b/openwhispr-ptt.py index 2451fb3..0ec52dc 100644 --- a/openwhispr-ptt.py +++ b/openwhispr-ptt.py @@ -13,6 +13,7 @@ Usage: sudo python3 openwhispr-ptt.py import subprocess import signal import sys +import time try: import evdev @@ -35,9 +36,14 @@ is_recording = False def send_whispr_toggle(): + """Send Ctrl+` to OpenWhispr via xdotool. + + Uses --clearmodifiers to release any physically held keys first, + so the simulated Ctrl+` isn't mangled into Ctrl+Alt+`. + """ try: subprocess.run( - ["xdotool", "key", WHISPR_HOTKEY], + ["xdotool", "key", "--clearmodifiers", WHISPR_HOTKEY], timeout=2, capture_output=True, ) @@ -108,6 +114,7 @@ def main(): # Stop when either released if is_recording and not (ctrl_held and alt_held): + time.sleep(0.05) # Let key release propagate to X11 send_whispr_toggle() is_recording = False print("\033[0m○ Stopped", flush=True)