-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Text input does not work in terminal emulators (GNOME Terminal, xterm) - only ^M visible
Description
QSpeak transcription works correctly in GUI applications (e.g., VS Code, text editors), but fails to input any text in terminal emulators. After speaking and having QSpeak process the transcription, no text appears in the terminal. However, when pressing Enter afterward, the terminal displays ^M (carriage return character), indicating that some input events are being received but not the actual text content.
Environment
- OS: Pop!_OS (Ubuntu-based)
- Display Server: X11 (
echo $XDG_SESSION_TYPEreturnsx11) - Terminal: GNOME Terminal (
gnome-terminal-) - TERM variable:
xterm-256color - QSpeak Hotkey: F6 (simple key, no modifiers)
- xdotool installed: Yes (
/usr/bin/xdotool)
Steps to Reproduce
- Open GNOME Terminal
- Ensure terminal window has focus
- Press F6 to start QSpeak recording
- Speak some text (e.g., "hello world")
- Press F6 to stop recording and trigger transcription
- Observe that no text appears in the terminal
- Press Enter
- Observe
^Mcharacter appears
Expected Behavior
Transcribed text should appear in the terminal at the cursor position, the same way it works in GUI applications like VS Code.
Actual Behavior
- No visible text is typed into the terminal
- Only
^M(carriage return,\r) appears after pressing Enter - This suggests keypress events may be partially reaching the terminal but the actual character input is being rejected or lost
Additional Testing Performed
xdotool works manually
Running xdotool type --delay 50 "hello from xdotool" in a separate window successfully types text into GNOME Terminal when it has focus. This confirms:
- xdotool itself works with the terminal
- The terminal accepts synthetic keyboard input via XTEST
- The issue is specific to how QSpeak sends input
GUI applications work fine
QSpeak correctly inputs transcribed text into:
- Visual Studio Code
- Other GUI text editors
Possible Causes
Based on research, this could be related to:
-
enigo library behavior: QSpeak likely uses the
enigoRust crate for input simulation, which useslibxdo(xdotool's library) on Linux. There may be differences in how enigo sends events compared to direct xdotool usage. -
Missing
--clearmodifiersequivalent: The enigo library may not be clearing active modifiers before typing, which can cause issues (see [enigo issue #83](Clear modifiers before typing enigo-rs/enigo#83)). -
Window targeting: If enigo is sending events to a specific window ID rather than using XTEST to type to the active window, terminals may reject these events due to the
send_eventflag (see [xdotool SENDEVENT NOTES](https://manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html#sendevent%20notes)). -
Line ending handling: The
^Mcharacter suggests carriage returns (\r) are being sent but not translated properly by the terminal.
Suggested Solutions
-
Add a clipboard-paste mode: Instead of simulating keystrokes, copy transcribed text to clipboard and simulate
Ctrl+Shift+Vfor terminal windows. This is more reliable for terminals. -
Use XTEST API: Ensure enigo is using the XTEST extension (typing to active window) rather than XSendEvent (sending to specific window ID).
-
Clear modifiers: Call
xdo_clear_active_modifiersbefore typing to prevent modifier key interference. -
Detect terminal windows: Optionally detect when the focused window is a terminal emulator and use an alternative input method.
Related Issues / References
- [enigo: Clear modifiers before typing (#83)](Clear modifiers before typing enigo-rs/enigo#83)
- [enigo: Support linux via x11 without xdotools (#112)](Support linux via x11 without xdotools enigo-rs/enigo#112)
- [xdotool SENDEVENT NOTES](https://manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html#sendevent%20notes)
- [Similar app "Handy" notes about enigo limitations](https://github.com/cjpais/Handy) - falls back to xdotool/ydotool directly due to enigo compatibility issues
Workaround Requests
Would it be possible to add an option for "clipboard paste mode" that:
- Copies transcribed text to clipboard
- Simulates
Ctrl+Shift+V(standard terminal paste shortcut)
This would provide a reliable workaround for terminal users.
Thank you for this great tool! Happy to provide any additional debugging information needed.