#clipboard #image

arboard

Image and text handling for the OS clipboard

6 releases (stable)

new 1.2.0 Apr 6, 2021
1.1.0 Dec 29, 2020
1.0.2 Oct 29, 2020
1.0.1 Sep 12, 2020
0.1.1 Sep 6, 2020

#84 in Operating systems

Download history 46/week @ 2020-12-20 186/week @ 2020-12-27 465/week @ 2021-01-03 384/week @ 2021-01-10 207/week @ 2021-01-17 336/week @ 2021-01-24 291/week @ 2021-01-31 236/week @ 2021-02-07 332/week @ 2021-02-14 387/week @ 2021-02-21 305/week @ 2021-02-28 357/week @ 2021-03-07 329/week @ 2021-03-14 206/week @ 2021-03-21 355/week @ 2021-03-28 260/week @ 2021-04-04

1,346 downloads per month
Used in 4 crates (3 directly)

MIT/Apache

110KB
2.5K SLoC

Latest version Documentation

General

This is a cross-platform library for interacting with the clipboard. It allows to copy and paste both text and image data in a platform independent way on Linux, Mac, and Windows.

Linux

The Linux implementation uses the X protocol by default for managing the clipboard but fear not because Wayland works with the X11 protocoll just as well. Furthermore this implementation uses the Clipboard selection (as opposed to the primary selection) and it sends the data to the clipboard manager when the application exits so that the data placed onto the clipboard with your application remains to be available after exiting.

There's also an optional wayland data control backend through the wl-clipboard-rs crate. This can be enabled using the wayland-data-control feature. When enabled this will be prioritized over the X11 backend, but if the initialization fails, the implementation falls back to using the X11 protocol automaticaly. Note that in my tests the wayland backend did not keep the clipboard contets after the process exited. (Although neither did the X11 backend on my Wayland setup).

Example

use arboard::Clipboard;

fn main() {
	let mut clipboard = Clipboard::new().unwrap();
	println!("Clipboard text was: {}", clipboard.get_text().unwrap());

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

Yet another clipboard crate

This is a fork of rust-clipboard. The reason for forking instead of making a PR is that rust-clipboard is not being maintained anymore. Furthermore note that the API of this crate is considerably different from that of rust-clipboard. There are already a ton of clipboard crates out there which is a bit unfortunate; I don't know why this is happening but while it is, we might as well just start naming the clipboard crates after ourselves. This one is arboard which stands for Artur's clipboard.

Dependencies

~0.4–4MB
~81K SLoC