Release all modifiers before sending clean Ctrl+grave sequence

Use explicit keyup ctrl alt super first, then the exact working
sequence: keydown ctrl, key grave, keyup ctrl.

https://claude.ai/code/session_01XKYC1basxdwtHy71tky7xm
This commit is contained in:
Claude
2026-03-25 20:40:47 +00:00
parent 6991fdbbee
commit 124fc8bc5b
+4 -5
View File
@@ -38,18 +38,17 @@ is_recording = False
def send_whispr_toggle():
"""Send Ctrl+` to OpenWhispr via xdotool.
We first release Alt (which we're physically holding), send Ctrl+grave,
then re-press Alt. This way OpenWhispr sees clean Ctrl+` without
the Alt modifier corrupting it.
Release all held modifiers first, then send the full
keydown ctrl, key grave, keyup ctrl sequence cleanly.
"""
try:
subprocess.run(
["xdotool", "keyup", "alt"],
["xdotool", "keyup", "ctrl", "alt", "super"],
timeout=2,
capture_output=True,
)
subprocess.run(
["xdotool", "key", WHISPR_HOTKEY],
["xdotool", "keydown", "ctrl", "key", "grave", "keyup", "ctrl"],
timeout=2,
capture_output=True,
)