`set_text` not copying to X11 clipboard
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
however, waiting a second before program exists fixes the problem (https://github.com/sigoden/aichat/issues/160)
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??
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
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
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.