Skip to content
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

[BUG] Doesn't work on Linux #3

Open
murlakatamenka opened this issue Feb 28, 2024 · 4 comments
Open

[BUG] Doesn't work on Linux #3

murlakatamenka opened this issue Feb 28, 2024 · 4 comments

Comments

@murlakatamenka
Copy link

Hi, thanks for the program.


It doesn't work on Linux because of the reasons explained in copypasta_ext (link):

A clipboard library providing useful extensions for the copypasta library.

I had a growing annoyance with copypasta, because the clipboard is cleared on the Linux/X11 platform when your application exits as per X11 design. The crate maintainer didn't want to implement workarounds (for valid reasons). This copypasta-ext crate provides additional clipboard contexts that solve this, along with a few other additions.

If you're willing to fix it, then switching to copypasta_ext and using its copypasta_ext::x11_fork::ClipboardContext is sufficient (doc):

use copypasta_ext::prelude::*;
use copypasta_ext::x11_fork::ClipboardContext;

let mut ctx = ClipboardContext::new()?;

Alternative is to use

// no imports needed
let mut ctx = copypasta_ext::try_context().unwrap("failed to get clipboard context);

but it may use other binaries like xsel or wl-copy under the hood.

@printfn
Copy link
Owner

printfn commented Feb 28, 2024

Right, in that case using copypasta_ext probably makes sense. I might go and implement that!

@printfn
Copy link
Owner

printfn commented Feb 28, 2024

I've pushed the change to the main branch, would you be able to double-check that it works for you? It is a bit unfortunate that copypasta_ext pulls in an older version of copypasta.

@murlakatamenka
Copy link
Author

I've pushed the change to the main branch, would you be able to double-check that it works for you?

Yes, it works now, at least

echo -e ' foo\n' | bp
bp

produces an expected outcome foo

I've checked both approaches before submitting the issue though :)

Some extra details to consider. If runtime detection is used, then it integrates better with current de-facto standard wl-{copy,paste}
utilities, i.e. you can copy with pb, then paste with wl-paste > /tmp/screenshot.png. Kinda defeats the purpose of having a single pb instead, right?


It is a bit unfortunate that copypasta_ext pulls in an older version of copypasta.

That's true, somehow copypasta is pinned at specific =0.8.2 for some reason.
I've submitted a PR, let's see how it goes:

https://gitlab.com/timvisee/copypasta-ext/-/merge_requests/2

@murlakatamenka
Copy link
Author

@printfn Tim merged that PR. It's not on crates.io yet (still 0.4.4), but you can use git as a crate source for now.

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

No branches or pull requests

2 participants