Skip to content

Conversation

@leakedmemory
Copy link
Contributor

@leakedmemory leakedmemory commented Dec 28, 2025

Problem

On Wayland, arboard's set_text() reports success but the clipboard remains empty. This is due to Linux clipboard ownership - the application must keep the Clipboard object alive until another app requests the data (documented in arboard's README under "Clipboard Ownership").

arboard provides a .wait() method to block until data is received, but this hangs indefinitely in TUI applications since nothing immediately requests the clipboard. The README suggests storing the Clipboard long-term or using .wait(), but neither works reliably for interactive TUI apps that can't block the main thread.

Solution

Detect Wayland sessions via WAYLAND_DISPLAY and use wl-copy directly, falling back to arboard for X11/macOS/Windows. wl-copy handles clipboard ownership correctly by forking to background.

This introduces wl-clipboard as a runtime dependency for Wayland environments.

Problem: `arboard` may use X11 via XWayland on Wayland sessions, causing silent
clipboard failures where the copy appears successful but nothing is actually
copied.

Solution: Detect Wayland sessions via WAYLAND_DISPLAY and use wl-copy directly,
falling back to arboard for X11/macOS/Windows.
@lusingander
Copy link
Owner

Thank you for your pull request.
Rather than handling each case individually, what do you think about allowing commands to be specified individually in a config file for execution during copy operations? For example, I'm picturing something like this format:

[core.external]
# clipboard = "Auto" # In this case, the existing processing by arboard is called
clipboard = { "Custom" = { commands = ["wl-copy"] } } # In this case, the specified command is executed

@leakedmemory
Copy link
Contributor Author

Sure, makes total sense. Later today I can do that.

@leakedmemory
Copy link
Contributor Author

Done. Let me know if you have any more suggestions.

@lusingander lusingander changed the title Fix clipboard copy on XWayland by using wl-copy directly Add configurable clipboard command support Dec 29, 2025
@lusingander lusingander merged commit f984ac4 into lusingander:master Dec 29, 2025
8 checks passed
@lusingander
Copy link
Owner

Looks good, thank you!

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.

2 participants