pub trait ClipboardExtLinux {
    fn set_text_with_clipboard(
        &mut self,
        text: String,
        clipboard: LinuxClipboardKind
    ) -> Result<(), Error>; fn get_text_with_clipboard(
        &mut self,
        clipboard: LinuxClipboardKind
    ) -> Result<String, Error>; }
Expand description

Linux has a concept of clipboard “selections” which tend to be used in different contexts. This trait extension provides a way to get/set to a specific clipboard (the default LinuxClipboardKind::Clipboard being used for the common platform API).

See https://specifications.freedesktop.org/clipboards-spec/clipboards-0.1.txt for a better description of the different clipboards.

Examples

use arboard::{Clipboard, ClipboardExtLinux, LinuxClipboardKind};
let mut ctx = Clipboard::new().unwrap();

ctx.set_text_with_clipboard(
    "This goes in the traditional (ex. Copy & Paste) clipboard.".to_string(),
    LinuxClipboardKind::Clipboard
).unwrap();

ctx.set_text_with_clipboard(
    "This goes in the primary keyboard. It's typically used via middle mouse click.".to_string(),
    LinuxClipboardKind::Primary
).unwrap();

Required Methods

Places the text onto the selected clipboard. Any valid utf-8 string is accepted. If wayland support is enabled and available, attempting to use the Secondary clipboard will return an error.

Fetches utf-8 text from the selected clipboard and returns it. If wayland support is enabled and available, attempting to use the Secondary clipboard will return an error.

Implementors