Skip to content

Fix ydotool virtual input device leak (#7)#8

Merged
csheaff merged 7 commits intomainfrom
fix/typing-tool-fallback
Feb 15, 2026
Merged

Fix ydotool virtual input device leak (#7)#8
csheaff merged 7 commits intomainfrom
fix/typing-tool-fallback

Conversation

@csheaff
Copy link
Owner

@csheaff csheaff commented Feb 15, 2026

Summary

  • Add typing-tool fallback chain (wtypeydotool+daemon → xdotoolydotool with warning) to avoid leaking kernel virtual input devices when using bare ydotool without ydotoold
  • New type_text() function with auto-detection, configurable via TALKTYPE_TYPE_CMD (matches existing ffmpeg/pw-record pattern for recording)
  • Warn once per session when falling back to bare ydotool (stderr + desktop notification)

Test plan

  • All 13 talktype tests pass (including 2 new: wtype preference, TYPE_CMD override)
  • shellcheck clean
  • Manual: run on Wayland with wtype installed — should use wtype, no device leak
  • Manual: run with TALKTYPE_TYPE_CMD=xdotool — should use xdotool
  • Manual: run with only bare ydotool — should warn about missing daemon

🤖 Generated with Claude Code

…ak (#7)

Each ydotool invocation without ydotoold creates a kernel virtual input
device that persists until reboot. Add auto-detection fallback chain
(wtype → ydotool+daemon → xdotool → ydotool with warning) configurable
via TALKTYPE_TYPE_CMD, matching the existing ffmpeg/pw-record pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

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 fixes a virtual input device leak issue with ydotool by implementing a typing tool fallback chain and adding proper daemon detection. The changes introduce flexibility in choosing typing tools while warning users about the device leak issue when using bare ydotool without its daemon.

Changes:

  • Implements automatic typing tool selection with fallback chain: wtype (Wayland) → ydotool+daemon → xdotool (X11) → ydotool with warning
  • Adds TALKTYPE_TYPE_CMD configuration variable for manual tool override
  • Includes one-time-per-session warning system for bare ydotool usage

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
talktype Adds type_text() function with auto-detection logic and warn_ydotool_no_daemon() for user warnings; updates check_deps() to handle multiple typing tools
test/talktype.bats Adds tests for wtype preference and TYPE_CMD override; updates existing tests to set WAYLAND_DISPLAY and TYPE_CMD; updates dependency test for multiple tools
test/mocks/wtype New mock for wtype typing tool that logs invocations
test/mocks/xdotool New mock for xdotool typing tool that logs invocations
README.md Documents new typing tool requirements and configuration options; updates architecture diagram
CLAUDE.md New developer documentation file describing project architecture, testing, and conventions
Makefile Adds wtype to system dependencies
.github/workflows/ci.yml Adds wtype to CI test dependencies

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

csheaff and others added 6 commits February 15, 2026 10:05
…dge cases

- Add pgrep mock for deterministic tests (default: no ydotoold running)
- Add test for ydotool+daemon detection path
- Add test for bare ydotool warning (once-per-session)
- Error explicitly if auto-detection finds no typing tool
- Update line counts in CLAUDE.md and README.md
- Update architecture description in CLAUDE.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
wtype can be installed but fail at runtime if the compositor doesn't
support virtual-keyboard-unstable-v1 (e.g. GNOME). Change auto mode
to actually try each tool and fall through on failure, rather than
just checking if the binary exists.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bare ydotool without ydotoold leaks kernel input devices that can crash
the system. Auto mode now only uses safe tools (wtype, ydotool+daemon,
xdotool) and errors with clear instructions if none work. Users can
still opt in to bare ydotool via TALKTYPE_TYPE_CMD=ydotool.

Also remove Parakeet backend from README (CTC model outputs lowercase
without punctuation, not useful for typing).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On GNOME Wayland, wtype fails (no virtual-keyboard protocol) and
xdotool fails (X11 events ignored by Wayland apps). Bare ydotool is
the only working option. Testing shows ydotool 0.1.8-3build1 cleans
up its virtual input devices, so allow it as a last resort with a
once-per-session warning about the potential device leak.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
xdotool sends X11 key events that Wayland-native apps silently ignore,
yet returns exit 0. Only try xdotool on pure X11 sessions (DISPLAY set,
WAYLAND_DISPLAY unset) so it doesn't block the ydotool fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@csheaff csheaff merged commit 423611a into main Feb 15, 2026
6 checks passed
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.

1 participant