#clipboard #x11 #ext #extension #context #fork #set

clipboard-ext

A clipboard library providing useful extensions for rust-clipboard

3 unstable releases

0.2.0 Feb 13, 2020
0.1.1 Feb 13, 2020
0.1.0 Feb 13, 2020

#858 in Unix APIs

Download history 14/week @ 2024-07-21 56/week @ 2024-07-28 22/week @ 2024-08-04 24/week @ 2024-08-11 17/week @ 2024-08-18 14/week @ 2024-08-25 14/week @ 2024-09-01 15/week @ 2024-09-08 13/week @ 2024-09-15 24/week @ 2024-09-22 17/week @ 2024-09-29 2/week @ 2024-10-06 19/week @ 2024-10-13 9/week @ 2024-10-20 14/week @ 2024-10-27 27/week @ 2024-11-03

69 downloads per month
Used in 3 crates

MIT/Apache

32KB
340 lines

Build status on GitLab CI Newest release on crates.io Documentation Number of downloads on crates.io Project license

rust-clipboard-ext

A clipboard library providing useful extensions for the rust-clipboard library.

I had a growing annoyance with rust-clipboard, because the clipboard is cleared on the Linux/X11 platform when your application exists as per X11 design. The crate maintainer didn't want to implement workarounds (for valid reasons). This clipboard-ext crate provides additional clipboard contexts that solve this, along with a few other additions.

Here are some of these additions:

Example

Get and set clipboard contents. Keeps contents in X11 clipboard after exit by forking the process. Falls back to standard clipboard provider on non X11 platforms. See x11_fork module for details.

use clipboard_ext::prelude::*;
use clipboard_ext::x11_fork::ClipboardContext;

fn main() {
    let mut ctx = ClipboardContext::new().unwrap();
    println!("{:?}", ctx.get_contents());
    ctx.set_contents("some string".into()).unwrap();
}

Get and set clipboard contents. Keeps contents in X11 clipboard after exit by invoking xclip/xsel. Falls back to standard clipboard provider on non X11 platforms. See x11_bin module for details.

use clipboard_ext::prelude::*;
use clipboard_ext::x11_bin::ClipboardContext;

fn main() {
    let mut ctx = ClipboardContext::new().unwrap();
    println!("{:?}", ctx.get_contents());
    ctx.set_contents("some string".into()).unwrap();
}

Requirements

  • Rust 1.40 or above
  • Same requirements as rust-clipboard
  • Requirements noted in specific clipboard context modules

Special thanks

  • to aweinstock314 for building rust-clipboard
  • to everyone involved in all crate dependencies used

License

This project is dual-licensed under the MIT and Apache2 license.

Dependencies

~0–5MB
~15K SLoC