arboard: `set_text` doesn't work, despite not showing errors

fn main() -> Result<(), Box<dyn Error>> {
    arboard::Clipboard::new()
        .unwrap()
        .set_text("asdf")
        .unwrap();
    Ok(())
}

this is the simple snippet I used to consistently replicate the issue.
nothing seems to happen — my clipboard is not updated, nor is it invalidated. whatever was in my clipboard previously stays there, untouched.

I thought that it was maybe my clipboard daemon (cliphist) making things messy, so I disabled both of the services I run for it to check. nope, nothing changed.

I’m on niri (wayland compositor). There’s an option that allows you to disable the primary clipboard (keeping the normal clipboard working), so I thought it could be that. nope! not only does my config have that disableament disabled, I deleted the whole section just to make sure.

I thought that maybe arboard defaults to the primary clipboard, and I’ve been trying to paste from the system clipboard for the tests. after running the program, I middle clicked to paste from my primary clipboard, but that didn’t turn into “asdf” either.

This is maybe not that useful in terms of information, but I wanted to showcase that I have tried diagnosing the issue. At this point I don’t know what else I would even check; I’m unfamiliar with the inner workings of the clipboard.
Please tell me if there is anything else significant that I could share, that would help us find out where the issue is coming from.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19

Most upvoted comments

alright that makes sense, thank you for answering!

No problem at all, and thank you for working with me through the different steps here. I subscribed to that pik PR as well to see how it goes.

but that’s a whole different rant. could probably write a blog post about it hahaaha

Someone wrote a good one back in 2008, pre-Wayland: https://web.archive.org/web/20120417230723/https://elliotth.blogspot.com/2008/08/desktop-linux-suckage-clipboard.html. All of the design warts followed into Wayland’s clipboard handling though, so not much has really changed for better or worse.

I’m very happy to hear a positive signal about the new documentation, thank you!

it might simply not have enough time to process it, which is probably the source of my other clipboard issues as well

I’ve found this to be the most likely case in my all investigations so far. If nothing is synchronizing the exit of your entire process and arboard’s background thread, requests won’t have a chance to be handled. In some testing I did last week I found that it was within single-digit ms between a set and premature drop on an Apple Silicon laptop, which is definitely not enough time for a clipboard manager to roundtrip anything.

the highest chance is that I simply didn’t try adding the feature flag in pik, and only tried to in my program that exited too quickly. I used arboard 3.6 rather than 3.5 in pik because of the otherwise version conflict it was having.