#clipboard #image

arboard

Image and text handling for the OS clipboard

16 stable releases (3 major)

3.3.1 Feb 12, 2024
3.3.0 Nov 20, 2023
3.2.1 Aug 29, 2023
3.2.0 Nov 4, 2022
0.1.1 Sep 6, 2020

#2 in Images

Download history 63720/week @ 2023-11-07 71689/week @ 2023-11-14 61621/week @ 2023-11-21 63027/week @ 2023-11-28 63389/week @ 2023-12-05 59603/week @ 2023-12-12 50798/week @ 2023-12-19 43247/week @ 2023-12-26 66878/week @ 2024-01-02 63853/week @ 2024-01-09 73712/week @ 2024-01-16 72801/week @ 2024-01-23 79236/week @ 2024-01-30 73074/week @ 2024-02-06 79447/week @ 2024-02-13 64623/week @ 2024-02-20

309,552 downloads per month
Used in 381 crates (113 directly)

MIT/Apache

110KB
2K SLoC

Arboard (Arthur's Clipboard)

Latest version Documentation MSRV

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.

GNU/Linux

The GNU/Linux implementation uses the X protocol by default for managing the clipboard but fear not because Wayland works with the X11 protocol 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 automatically. Note that in my tests the wayland backend did not keep the clipboard contents 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).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 any more. 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.3–18MB
~192K SLoC