Fix Ctrl+grave being sent without Ctrl due to --clearmodifiers

--clearmodifiers releases ALL modifiers including Ctrl, so xdotool
sends bare grave (types 'v'). Instead, explicitly release only Alt
before sending Ctrl+grave so OpenWhispr receives the correct combo.

https://claude.ai/code/session_01XKYC1basxdwtHy71tky7xm
This commit is contained in:
Claude
2026-03-25 20:37:05 +00:00
parent 9137bd2d80
commit 6991fdbbee
+9 -3
View File
@@ -38,12 +38,18 @@ 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+`.
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.
"""
try:
subprocess.run(
["xdotool", "key", "--clearmodifiers", WHISPR_HOTKEY],
["xdotool", "keyup", "alt"],
timeout=2,
capture_output=True,
)
subprocess.run(
["xdotool", "key", WHISPR_HOTKEY],
timeout=2,
capture_output=True,
)