Switch PTT hotkey from Ctrl+Super to Ctrl+Alt

Super key is intercepted by Cinnamon/window managers before reaching
the app. Ctrl+Alt is a better choice — works reliably on all DEs.

https://claude.ai/code/session_01XKYC1basxdwtHy71tky7xm
This commit is contained in:
Claude
2026-03-25 20:01:10 +00:00
parent aa8f40039a
commit 723436dae9
+10 -9
View File
@@ -2,9 +2,9 @@
"""
openwhispr-ptt.py — Push-to-talk wrapper for OpenWhispr
Turns Ctrl+Super (hold) into Ctrl+` toggle pairs:
- Press Ctrl+Super → sends Ctrl+` to START dictation
- Release Ctrl+Super → sends Ctrl+` to STOP dictation
Turns Ctrl+Alt (hold) into Ctrl+` toggle pairs:
- Press Ctrl+Alt → sends Ctrl+` to START dictation
- Release Ctrl+Alt → sends Ctrl+` to STOP dictation
Requires: pynput, xdotool
Usage: python3 openwhispr-ptt.py
@@ -27,10 +27,11 @@ except ImportError:
# The key combo YOU hold to talk
PTT_MODIFIER = keyboard.Key.ctrl_l
PTT_KEY = keyboard.Key.cmd # Super/Windows key
PTT_KEY = keyboard.Key.alt_l
# Also accept right Ctrl
# Also accept right-hand variants
PTT_MODIFIER_ALT = keyboard.Key.ctrl_r
PTT_KEY_ALT = keyboard.Key.alt_r
# The key combo OpenWhispr uses (Ctrl+`)
# We simulate this via xdotool for reliability with Electron apps
@@ -67,7 +68,7 @@ def on_press(key):
# Track modifier state — ignore key repeat (already True)
if key in (PTT_MODIFIER, PTT_MODIFIER_ALT):
ctrl_held = True
elif key == PTT_KEY:
elif key in (PTT_KEY, PTT_KEY_ALT):
super_held = True
# Start recording when both held and not already recording
@@ -87,7 +88,7 @@ def on_release(key):
if key in (PTT_MODIFIER, PTT_MODIFIER_ALT):
ctrl_held = False
released_ptt = True
elif key == PTT_KEY:
elif key in (PTT_KEY, PTT_KEY_ALT):
super_held = False
released_ptt = True
@@ -103,8 +104,8 @@ def main():
print("═══════════════════════════════════════════")
print(" OpenWhispr Push-to-Talk")
print("═══════════════════════════════════════════")
print(" Hold: Ctrl + Super → start dictation")
print(" Release: Ctrl + Super → stop dictation")
print(" Hold: Ctrl + Alt → start dictation")
print(" Release: Ctrl + Alt → stop dictation")
print(" Quit: Ctrl + C")
print("═══════════════════════════════════════════")
print("Listening...\n")