#clipboard #image

arboard

Image and text handling for the OS clipboard

4 releases (2 stable)

1.0.2 Oct 29, 2020
1.0.1 Sep 12, 2020
0.1.1 Sep 6, 2020
0.1.0 Sep 6, 2020

#86 in Images

Download history 9/week @ 2020-08-31 87/week @ 2020-09-07 11/week @ 2020-09-14 15/week @ 2020-09-21 20/week @ 2020-09-28 60/week @ 2020-10-05 38/week @ 2020-10-12 72/week @ 2020-10-19 44/week @ 2020-10-26 43/week @ 2020-11-02 54/week @ 2020-11-09 21/week @ 2020-11-16 23/week @ 2020-11-23

109 downloads per month
Used in emulsion

MIT/Apache

110KB
2K SLoC

Latest version Documentation

General

This is a cross-platform library for interacting with the clipboard. It can get and set both text and image data in a platform independent way on Linux, Mac, and Windows.

The Linux implementation uses the X protocol 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.

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.

Prerequisites

On Linux you need the x11 library when building your application. Install it with something like:

sudo apt-get install xorg-dev

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);
}

Dependencies

~0.4–1.7MB
~34K SLoC