Skip to content

feat: Linux local build script, install workflow, and Wayland native support - #272

Open
saurondark22 wants to merge 3 commits into
theJayTea:mainfrom
saurondark22:Linux-installation
Open

feat: Linux local build script, install workflow, and Wayland native support#272
saurondark22 wants to merge 3 commits into
theJayTea:mainfrom
saurondark22:Linux-installation

Conversation

@saurondark22

@saurondark22 saurondark22 commented Jun 5, 2026

Copy link
Copy Markdown

Linux local build script, install workflow, and Wayland native support

description

A complete local-install experience for Linux users, plus native Wayland
clipboard + keystroke injection so the app works in native Wayland apps
(not only XWayland).

Changes

Local install + docs

  • build-and-install-local-linux.sh — builds locally and installs with a launcher icon + app menu entry
  • install-local-linux.sh — dependency checks, venv creation, icon install, desktop entry, optional autostart
  • To Compile the Application Yourself.md — clearer venv setup + per-distro system dependency instructions (X11 vs Wayland)
  • To Run Writing Tools Directly from the Source Code.md — post-install usage
  • .gitignore — venvs, packaging artifacts, dist folders, PyInstaller specs

Wayland native support (fixes #93, #34)

On Wayland (KDE/KWin) Writing Tools only worked in XWayland windows.
Native Wayland apps got stale clipboard sent to the AI and no paste-back.
Three independent failures, each fixed:

  1. pyperclip blocks on wl-copy. With no xclip/xsel, pyperclip uses
    wl-copy, which forks a background server and doesn't exit —
    subprocess.run(capture_output=True) hangs. Clipboard clear (capture)
    and write (paste-back) never complete.
  2. pynput injection dead on native Wayland. pynput's Linux backend is
    X11/XTest (_xorg.py) — only reaches XWayland windows. Upstream PR feat(linux): Add Wayland support for text and window title capture #229
    swapped the clipboard read to wl-paste but left injection on pynput,
    so the selection never got copied; wl-paste read stale content (exact
    [Linux] Application does not get triggered when hot-key is pressed #93 symptom).
  3. ydotool key emits nothing as a single string.
    ydotool key "29:1 46:1 46:0 29:0" returns exit 0 but writes zero
    uinput events. Tokens must be separate argv elements. Silent no-op even
    with a healthy daemon + accessible /dev/uinput.

The fix adds _wayland_io.py (~150 lines), used only when
XDG_SESSION_TYPE=wayland + wl-clipboard + ydotool present. Windows/X11
keep the original pyperclip+pynput path unchanged — new code lives
behind if _wayland_io.is_wayland_active(): guards, original logic moved
verbatim into else branches.

  • Clipboard: wl-copy/wl-paste with fork-and-detach pattern
    (Popen+DEVNULL+close_fds, fed via stdin). No more hangs.
  • Injection: ydotool key at uinput layer, keycodes as separate argv
    elements (KEY_LEFTCTRL=29, KEY_C=46, KEY_V=47). Reaches native Wayland
    • XWayland. Needs ydotoold running + input group.
  • Capture race: dropped clipboard clear on Wayland (Klipper re-offers
    it); poll until clipboard changes from backup instead of just
    non-empty.
  • Paste focus: WT_PASTE_SETTLE_MS env var (default 300ms on Wayland,
    0 on X11) lets KWin settle focus before Ctrl+V.

Verified live on CachyOS / KDE Plasma 6 / Wayland: ydotool key
Ctrl+A+Ctrl+C into a native KDE/Qt window captured the exact selected text;
clipboard backup/restore roundtrip clean.

vs PR #229

#229 took the right first step (wl-paste + session detect) but left
injection on pynput — the actual broken layer. Without Ctrl+C, wl-paste
reads stale clipboard. This completes the loop (native clipboard and
injection)

Why this matters

The Linux compile path was broken; this gives a one-command install +
desktop integration. Wayland support closes the long-standing #93/#34
native Wayland apps now capture and paste-back correctly instead of only
XWayland windows.

System deps (documented in install/compile docs)

  • X11: xclip — pynput handles injection via XTest.
  • Wayland: wl-clipboard + ydotool, then
    systemctl --user enable --now ydotool + sudo usermod -aG input $USER
    (log out/in). Without these, app auto-falls back to X11 path.

Files

  • Windows_and_Linux/_wayland_io.py (new) — detection + clipboard + injection
  • Windows_and_Linux/WritingToolApp.py — 3 call sites routed through Wayland guard (capture/poll/paste-back); X11/Windows branches untouched
  • Windows_and_Linux/build-and-install-local-linux.sh (new) — local build+install
  • Windows_and_Linux/install-local-linux.sh (new) — installer + Wayland dep notice
  • README's Linked Content/To Compile the Application Yourself.md — venv + system deps docs

- Add build-and-install-local-linux.sh for local install with launcher icon
- Update build docs with clearer venv setup, platform-specific activation, and Linux install steps
- Add autostart option and post-install usage info
- Ignore Python venv, packaging, dist, and spec files in Windows_and_Linux
- Fix README link to point to main branch instead of specific commit
@saurondark22
saurondark22 marked this pull request as ready for review June 5, 2026 08:28
Create a virtual environment and install requirements in
build-and-install-local-linux.sh before running the installer.
Update compile instructions to reflect the new Linux build process.
pynput and pyperclip are unreliable on Wayland sessions: pynput only
reaches XWayland windows and pyperclip's wl-copy subprocess blocks.
Add a Wayland-native IO path using wl-clipboard and ydotool, with
automatic fallback to the existing X11 path when the tools are missing.

Also update the Linux installer and compile docs to list the required
system packages, and fix the Windows build workflow zip command.
@saurondark22 saurondark22 changed the title Add Linux local build script and update compile instructions feat: Add Linux local build script and update compile instructions Aug 16, 2026
@saurondark22 saurondark22 changed the title feat: Add Linux local build script and update compile instructions feat: add Linux local build script with improved Wayland support and updated instructions Aug 16, 2026
@saurondark22 saurondark22 changed the title feat: add Linux local build script with improved Wayland support and updated instructions feat: Linux local build script, install workflow, and Wayland native support Aug 16, 2026
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.

[Linux] Application does not get triggered when hot-key is pressed

1 participant