Skip to content

fix: detach wl-copy from parent process on Wayland clipboard copy#344

Open
ScriptingDad wants to merge 1 commit intosavedra1:mainfrom
ScriptingDad:fix/wayland-clipboard-setsid
Open

fix: detach wl-copy from parent process on Wayland clipboard copy#344
ScriptingDad wants to merge 1 commit intosavedra1:mainfrom
ScriptingDad:fix/wayland-clipboard-setsid

Conversation

@ScriptingDad
Copy link

I was having problems using clipse where copying from the TUI would appear to work but nothing could be pasted. After debugging, the issue is that when the clipse terminal window closes after selection, it kills the wl-copy child process along with it — and on Wayland, wl-copy must
stay alive to hold the clipboard seat. When it dies, the clipboard is immediately empty.

The fix is a 3-line change: use cmd.Start() with Setsid: true instead of cmd.Run(). This puts wl-copy in its own process session so it survives the parent exiting. When a new item is copied, the old wl-copy exits naturally as it loses clipboard ownership to the new one — no process
leak.

Environment: Ubuntu 22.04, Sway. My work machine on Ubuntu 24.04 doesn't exhibit this — likely because it has a clipboard persistence daemon running that masks the bug.

I used Kiro to help locate and implement the fix.

wl-copy must stay alive to hold the Wayland clipboard seat. Using
cmd.Run() caused it to be killed when the clipse TUI exited, clearing
the clipboard. Switching to cmd.Start() with Setsid:true detaches
wl-copy into its own session so it survives the parent process exit.
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