#clipboard #winapi #windows #winapi-clipboard

clipboard-master

Simple utility crate to monitor clipboard changes

13 releases (7 stable)

4.0.0 Nov 27, 2025
4.0.0-beta.6 Jun 4, 2024
4.0.0-beta.5 Feb 6, 2024
3.1.3 Nov 23, 2021
0.1.0 Mar 17, 2017

#259 in Unix APIs

Download history 185/week @ 2025-10-18 137/week @ 2025-10-25 107/week @ 2025-11-01 88/week @ 2025-11-08 159/week @ 2025-11-15 125/week @ 2025-11-22 124/week @ 2025-11-29 209/week @ 2025-12-06 155/week @ 2025-12-13 124/week @ 2025-12-20 94/week @ 2025-12-27 133/week @ 2026-01-03 95/week @ 2026-01-10 202/week @ 2026-01-17 149/week @ 2026-01-24 114/week @ 2026-01-31

578 downloads per month
Used in clip_tex

MIT license

23KB
396 lines

clipboard-master

Crates.io Docs.rs

Clipboard monitoring library.

Supported platforms

  • Windows - uses dummy window to receive messages when clipboard changes;
  • Linux - uses x11_clipboard
  • MacOS - uses polling via NSPasteboard::changeCount as there is no event notification.

Clipboard Master Library

This project exports Master struct that provides simple way to handle clipboard updates.

Example:

extern crate clipboard_master;

use clipboard_master::{Master, ClipboardHandler, CallbackResult};

use std::io;

struct Handler;

impl ClipboardHandler for Handler {
    fn on_clipboard_change(&mut self) -> CallbackResult {
        println!("Clipboard change happened!");
        CallbackResult::Next
    }

    fn on_clipboard_error(&mut self, error: io::Error) -> CallbackResult {
        eprintln!("Error: {}", error);
        CallbackResult::Next
    }
}

fn main() {
    let mut master = Master::new(Handler).expect("create new monitor");

    let shutdown = master.shutdown_channel();
    std::thread::spawn(move || {
        std::thread::sleep(core::time::Duration::from_secs(1));
        println!("I did some work so time to finish...");
        shutdown.signal();
    });
    //Working until shutdown
    master.run().expect("Success");
}

Dependencies

~0–8MB
~172K SLoC