copy/copy.rs
1//! Set the clipboard to the first argument and hold it until interrupted.
2
3use lamco_data_control::{Content, DataControl};
4
5fn main() -> lamco_data_control::Result<()> {
6 let text = std::env::args()
7 .nth(1)
8 .unwrap_or_else(|| "hello".to_owned());
9 let clipboard = DataControl::connect()?;
10 clipboard.set_selection(
11 Content::new()
12 .data("text/plain;charset=utf-8", text.clone())
13 .data("text/plain", text),
14 )?;
15 println!("clipboard set; press Ctrl-C to release it");
16 std::thread::park();
17 Ok(())
18}