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:
+10
-9
@@ -2,9 +2,9 @@
|
|||||||
"""
|
"""
|
||||||
openwhispr-ptt.py — Push-to-talk wrapper for OpenWhispr
|
openwhispr-ptt.py — Push-to-talk wrapper for OpenWhispr
|
||||||
|
|
||||||
Turns Ctrl+Super (hold) into Ctrl+` toggle pairs:
|
Turns Ctrl+Alt (hold) into Ctrl+` toggle pairs:
|
||||||
- Press Ctrl+Super → sends Ctrl+` to START dictation
|
- Press Ctrl+Alt → sends Ctrl+` to START dictation
|
||||||
- Release Ctrl+Super → sends Ctrl+` to STOP dictation
|
- Release Ctrl+Alt → sends Ctrl+` to STOP dictation
|
||||||
|
|
||||||
Requires: pynput, xdotool
|
Requires: pynput, xdotool
|
||||||
Usage: python3 openwhispr-ptt.py
|
Usage: python3 openwhispr-ptt.py
|
||||||
@@ -27,10 +27,11 @@ except ImportError:
|
|||||||
|
|
||||||
# The key combo YOU hold to talk
|
# The key combo YOU hold to talk
|
||||||
PTT_MODIFIER = keyboard.Key.ctrl_l
|
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_MODIFIER_ALT = keyboard.Key.ctrl_r
|
||||||
|
PTT_KEY_ALT = keyboard.Key.alt_r
|
||||||
|
|
||||||
# The key combo OpenWhispr uses (Ctrl+`)
|
# The key combo OpenWhispr uses (Ctrl+`)
|
||||||
# We simulate this via xdotool for reliability with Electron apps
|
# 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)
|
# Track modifier state — ignore key repeat (already True)
|
||||||
if key in (PTT_MODIFIER, PTT_MODIFIER_ALT):
|
if key in (PTT_MODIFIER, PTT_MODIFIER_ALT):
|
||||||
ctrl_held = True
|
ctrl_held = True
|
||||||
elif key == PTT_KEY:
|
elif key in (PTT_KEY, PTT_KEY_ALT):
|
||||||
super_held = True
|
super_held = True
|
||||||
|
|
||||||
# Start recording when both held and not already recording
|
# 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):
|
if key in (PTT_MODIFIER, PTT_MODIFIER_ALT):
|
||||||
ctrl_held = False
|
ctrl_held = False
|
||||||
released_ptt = True
|
released_ptt = True
|
||||||
elif key == PTT_KEY:
|
elif key in (PTT_KEY, PTT_KEY_ALT):
|
||||||
super_held = False
|
super_held = False
|
||||||
released_ptt = True
|
released_ptt = True
|
||||||
|
|
||||||
@@ -103,8 +104,8 @@ def main():
|
|||||||
print("═══════════════════════════════════════════")
|
print("═══════════════════════════════════════════")
|
||||||
print(" OpenWhispr Push-to-Talk")
|
print(" OpenWhispr Push-to-Talk")
|
||||||
print("═══════════════════════════════════════════")
|
print("═══════════════════════════════════════════")
|
||||||
print(" Hold: Ctrl + Super → start dictation")
|
print(" Hold: Ctrl + Alt → start dictation")
|
||||||
print(" Release: Ctrl + Super → stop dictation")
|
print(" Release: Ctrl + Alt → stop dictation")
|
||||||
print(" Quit: Ctrl + C")
|
print(" Quit: Ctrl + C")
|
||||||
print("═══════════════════════════════════════════")
|
print("═══════════════════════════════════════════")
|
||||||
print("Listening...\n")
|
print("Listening...\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user