Skip to content

feat: add optional push-to-talk hold mode#26

Open
mattlgroff wants to merge 1 commit intoknowall-ai:mainfrom
mattlgroff:fix/single-key-hold
Open

feat: add optional push-to-talk hold mode#26
mattlgroff wants to merge 1 commit intoknowall-ai:mainfrom
mattlgroff:fix/single-key-hold

Conversation

@mattlgroff
Copy link
Copy Markdown

Summary

  • Add optional push_to_talk config (false by default) to support hold-to-talk behavior without changing existing toggle behavior.
  • Update hotkey plumbing to support separate press/release callbacks for the native hotkey manager.
  • Wire main app logic so push_to_talk=true starts recording on key-down and stops on key-up (including single-key bindings like [\"alt\"]).
  • Update docs/config examples to show both toggle mode and hold-to-talk mode.

Why

On Ubuntu Wayland I needed a true hold-to-talk interaction (press and hold to record, release to finalize) instead of only press-to-toggle. This adds that behavior behind config so existing users keep current behavior.

Risks

  • Portal backend does not provide release events in this implementation, so push_to_talk=true may effectively behave as press-only when portal is used.
  • Some key combos may still conflict with desktop/global shortcuts.
  • Single-modifier binds (like alt) can have UX side effects depending on app/desktop behavior.

Relation To Other PR

This is paired with a separate Wayland hotkey backend PR. Together they gave me reliable hold-to-talk + typing on Ubuntu Wayland.

Validation

  • python3 -m py_compile src/turbo_whisper/config.py src/turbo_whisper/hotkey.py src/turbo_whisper/main.py
  • Manual validation on Ubuntu Wayland with hotkey=[\"alt\"] and push_to_talk=true.

Note

I couldn't find a CONTRIBUTING.md, so I kept this scoped and conservative. If you'd like a different split/style I can adjust.

@BenGWeeks BenGWeeks requested a review from Copilot February 20, 2026 00:48
@BenGWeeks
Copy link
Copy Markdown
Contributor

Apologies for the delay, I missed the notification.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an optional push-to-talk mode to Turbo Whisper, allowing users to hold the hotkey to record and release to stop, in addition to the existing toggle behavior. The feature is disabled by default to preserve backward compatibility.

Changes:

  • Added push_to_talk boolean configuration option (defaults to False)
  • Extended hotkey manager infrastructure to support separate press and release callbacks
  • Updated main application logic to handle push-to-talk mode by starting recording on key press and stopping on key release

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/turbo_whisper/config.py Added push_to_talk boolean field with clear documentation
src/turbo_whisper/hotkey.py Added on_deactivate callback parameter to hotkey managers; implemented release event handling in HotkeyManager with _combo_active state tracking
src/turbo_whisper/main.py Added _on_hotkey_activate and _on_hotkey_deactivate methods with mode-specific logic; conditionally pass callbacks based on push_to_talk setting
config.example.json Added push_to_talk: false to example configuration
README.md Updated documentation to show both toggle and hold-to-talk modes with examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +57
def __init__(
self,
hotkey_combo: list[str],
on_activate: Callable[[], None],
on_deactivate: Callable[[], None] | None = None,
):
"""Initialize portal hotkey manager."""
# Import here to make dependencies optional
import dbus
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib

self.callback = callback
self.on_activate = on_activate
self.on_deactivate = on_deactivate
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The on_deactivate parameter is accepted but never used in the PortalHotkeyManager implementation. This could be confusing for users who enable push-to-talk mode on systems using the portal backend, as the release event will never fire. Consider adding a comment in the __init__ method documenting that on_deactivate is ignored by this backend, or logging a warning when the manager is initialized with a non-None on_deactivate callback.

Copilot uses AI. Check for mistakes.
manager = PortalHotkeyManager(hotkey_combo, on_activate, on_deactivate)
print("Using xdg-desktop-portal for global hotkeys (Wayland)")
if on_deactivate:
print("Portal backend does not support release events; using press-only behavior")
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning message "Portal backend does not support release events; using press-only behavior" is printed when on_deactivate is provided, but this message doesn't clearly explain the user-facing consequence. When push-to-talk mode is enabled with the portal backend, recording won't stop on key release, which defeats the purpose of push-to-talk. Consider making this warning more explicit, such as: "Warning: Portal backend does not support push-to-talk mode (no key release events). Recording will only start on key press."

Suggested change
print("Portal backend does not support release events; using press-only behavior")
print(
"Warning: Portal backend does not support push-to-talk mode "
"(no key release events). Recording will only start on key press."
)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants