Skip to content

Fix freeze on copy when xclip is installed on Linux #1547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2023

Conversation

louisbourque
Copy link
Contributor

This Pull Request fixes/closes #1497

It changes the following:

  • It adds a boolean argument to determine if stderr should be piped, and sets it to false when running the xclip command.

I was able to reproduce the linked issue. If I run killall xclip then the UI resumes normal function. This issue started with e371153. Removing the .stderr(Stdio::piped()) line fixes the freezing, but breaks the error reporting.

xclip waits for input on stdin. Something about piping stderr and stdin seems to cause the program to continue waiting for input. I tried different arguments to pass to xclip to tell it to exit, but nothing I tried seemed to work. I tried writing \x03 (End of Text) and \x04 (End of Transmission) and a few others that may have indicated to xclip to close. I tried passing -l 1 (loop once then exit) which fixes the freezing, but results in the wrong thing being set on the clipboard. (It would always set the previous thing I copied, instead of the last)

In the end, passing a boolean to the function to indicate whether or not stderr should be piped seems to do the trick. If the command fails, we retry with xsel anyway, and report the error from that command. So the stderr output from xclip isn't needed.

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

@senekor
Copy link
Contributor

senekor commented Mar 5, 2023

Hello! Thanks for opening this. I'm having the exact same problem with wl-copy and your fix works with that as well:

if std::env::var("WAYLAND_DISPLAY").is_ok() {
	return exec_copy_with_args("wl-copy", &[], text, false);
}

@extrawurst extrawurst merged commit 45bb8a7 into gitui-org:master Mar 5, 2023
@extrawurst
Copy link
Collaborator

Thanks guys ❤️

@senekor senekor mentioned this pull request Mar 5, 2023
4 tasks
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.

Copy hash freeze gitui
3 participants