Skip to content

feat(clipboard): implement proper Linux file reference clipboard support#103

Merged
gregpriday merged 2 commits into
developfrom
feature/issue-102-implement-proper-linux-file
Feb 26, 2026
Merged

feat(clipboard): implement proper Linux file reference clipboard support#103
gregpriday merged 2 commits into
developfrom
feature/issue-102-implement-proper-linux-file

Conversation

@gregpriday
Copy link
Copy Markdown
Owner

Summary

Replaces the plain-text file:// URI fallback on Linux with proper clipboard file reference support using xclip (X11) and wl-copy (Wayland) with the correct MIME types recognised by GTK and KDE file managers.

Closes #102

Changes Made

  • Add _detectLinuxClipboardMethod() static helper that detects display protocol ($WAYLAND_DISPLAY / $DISPLAY) and desktop environment ($XDG_CURRENT_DESKTOP) and returns the correct { tool, args, payload } object
  • GTK-based desktops (GNOME, XFCE, Cinnamon, MATE, Budgie) and unknown DEs use x-special/gnome-copied-files MIME type with copy\nfile:///path payload
  • KDE desktops use text/uri-list MIME type with file:///path\r\n payload (RFC 2483 compliant)
  • X11 sessions use xclip -selection clipboard -t <mime>, Wayland sessions use wl-copy --type <mime>; Wayland takes priority when both $WAYLAND_DISPLAY and $DISPLAY are set
  • Add 2-second spawnSync timeout to prevent hanging on broken Wayland compositors
  • Trim env var checks to reject whitespace-only values
  • Graceful fallback to plain-text file:// URI copy when neither tool is installed or the spawn fails — no error shown to user
  • Expand unit tests from 1 to 44 tests covering all X11/Wayland × GTK/KDE combinations, synchronous throw path, URI encoding with spaces, case-insensitive DE detection, whitespace env var rejection

- Add _detectLinuxClipboardMethod() to detect display protocol and DE
- Use xclip on X11 and wl-copy on Wayland with correct MIME types
- GTK desktops (GNOME, XFCE, Cinnamon): x-special/gnome-copied-files
- KDE desktops: text/uri-list with CRLF line ending
- Unknown DEs default to GTK format as most widely supported
- Add 2s spawnSync timeout to prevent hanging on broken compositors
- Trim env var checks to reject whitespace-only values
- Fall back to plain-text file:// URI when tools are unavailable
- Add 25 unit tests covering all X11/Wayland/DE/fallback combinations
@gregpriday gregpriday merged commit 60c80ef into develop Feb 26, 2026
10 of 15 checks passed
@gregpriday gregpriday deleted the feature/issue-102-implement-proper-linux-file branch February 26, 2026 04:36
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.

Implement proper Linux file reference clipboard support for --as-reference

1 participant