aweinstock314 / rust-clipboard

System Clipboard interfacing library in Rust
Apache License 2.0
365 stars 75 forks source link

set_contents doesnt work for me #86

Open alexzanderr opened 2 years ago

alexzanderr commented 2 years ago

hello.

i have a minimal example.

    use clipboard::ClipboardProvider;
    use clipboard::ClipboardContext;

    let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
    ctx.set_contents(String::from("hello")).unwrap();

this should copy to clipboard the string hello and then it should be pasteable with control-v everywhere.

actuall result: doesnt do anything (doesnt copy to clipboard), the clipboard is empty.

here is some neofetch:

                 `ooo/                   OS: Manjaro Linux x86_64
                `+oooo:                  Host: GL553VD 1.0
               `+oooooo:                 Kernel: 5.10.105-1-MANJARO
               -+oooooo+:                Uptime: 51 mins
             `/:-:++oooo+:               Packages: 1955 (pacman)
            `/++++/+++++++:              Shell: zsh 5.8.1
           `/++++++++++++++:             Resolution: 1920x1080
          `/+++ooooooooooooo/`           DE: Xfce 4.16
         ./ooosssso++osssssso+`          WM: Xfwm4
        .oossssso-````/ossssss+`         WM Theme: borderless-windows
       -osssssso.      :ssssssso.        Theme: Matcha-dark-aliz [GTK2], Adwaita [GTK3
      :osssssss/        osssso+++.       Icons: Papirus-Dark [GTK2], Adwaita [GTK3]
     /ossssssss/        +ssssooo/-       Terminal: tmux
   `/ossssso+/:-        -:/+osssso+-     CPU: Intel i7-7700HQ (8) @ 3.800GHz
  `+sso+:-`                 `.-/+oso:    GPU: Intel HD Graphics 630
 `++:.                           `-/+/   GPU: NVIDIA GeForce GTX 1050 Mobile
 .`                                 `/   Memory: 10703MiB / 15890MiB
                                         GPU Driver: ASUSTeK Computer Inc. Device [104

specs:

what am i missing guys? why it doesnt work?

my DE is using X11 and i saw this merge here that it was implemented for x11

kyoheiu commented 1 year ago

Hi, maybe too late, but this issue will help (or not help) your problem. https://github.com/alacritty/copypasta/issues/49

alexzanderr commented 1 year ago

thanks for response, i will check it out.

PabloGmz96 commented 1 year ago

Hey, I just had the same issue but I discovered that set_contents method does not work without the get_contents method, it seems like they are interdependent, weird but true. I let you a full working example below...

use clipboard::ClipboardProvider;
use clipboard::ClipboardContext;

fn main() {
    let mut ctx: ClipboardContext = ClipboardProvider::new().unwrap();
    ctx.set_contents("My name is Pablo".to_owned()).unwrap();
    ctx.get_contents();
}