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

set_text not copying to X11 clipboard #143

Open
yoyobara opened this issue Apr 5, 2024 · 5 comments
Open

set_text not copying to X11 clipboard #143

yoyobara opened this issue Apr 5, 2024 · 5 comments

Comments

@yoyobara
Copy link

yoyobara commented Apr 5, 2024

running the following:

use arboard::Clipboard;

fn main() {
    let mut clipboard = Clipboard::new().unwrap();

    let the_string = "Hello, world!";
    clipboard.set_text(the_string).unwrap();
    println!("But now the clipboard text should be: \"{}\"", the_string);
}

nothing new seems to be copied to the clipboard. the previous thing in the clipboard is still there.

output of cargo run:

    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/exers`
But now the clipboard text should be: "Hello, world!"

my neofetch:

OS: Arch Linux x86_64 
Host: Inspiron 14 5420 
Kernel: 6.8.2-arch2-1 
Uptime: 16 hours, 11 mins 
Packages: 1131 (pacman) 
Shell: bash 5.2.26 
Resolution: 2240x1400 
DE: Plasma 6.0.3 
WM: KWin 
Theme: Breeze-Dark [GTK2], Breeze [GTK3] 
Icons: breeze-dark [GTK2/3] 
Terminal: tmux 
CPU: 12th Gen Intel i7-1255U (12) @ 4.700GHz 
GPU: Intel Alder Lake-UP3 GT2 [Iris Xe Graphics] 
GPU: NVIDIA GeForce MX570 
Memory: 4411MiB / 15682MiB 
@yoyobara
Copy link
Author

yoyobara commented Apr 5, 2024

however, waiting a second before program exists fixes the problem
(sigoden/aichat#160)

@yoyobara
Copy link
Author

yoyobara commented Apr 9, 2024

I just figured out that the case is a little different in linux, since the process is responsible for providing the clipboard until something new is copied.
so I managed to get it to work by spawning a thread that does just that.

but something doesn't add up; why waiting a second before exiting in the original problem worked??

@ktwrd
Copy link

ktwrd commented May 17, 2024

Same thing happens even if you call something else after calling set_text, wait 1s, then exit.

Currently trying to show a notification directly after calling set_text, waiting 1s, then exiting, but I still encounter the same issue.

Note: I am calling the set_text function inside of an async block while using tokio for async support.

Edit

Made an issue that shows an example of it not working #154

@Mikachu2333
Copy link

Me too. (Also X11 but I use KDE)

My system info.

Operating System: Debian GNU/Linux 12
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.1.0-23-amd64 (64-bit)
Graphics Platform: X11
Processors: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz
Memory: 15.4 GiB of RAM
Graphics Processor: Mesa Intel® Xe Graphics
Manufacturer: LENOVO
Product Name: 20WE
System Version: ThinkBook 14s Yoga ITL

@crumblingstatue
Copy link

but something doesn't add up; why waiting a second before exiting in the original problem worked??

Maybe it gives enough time for your clipboard manager to pick up the contents.

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

4 participants