https://github.com/doumanash/clipboard-master
Clipboard monitoring utility
https://github.com/doumanash/clipboard-master
clipboard clipboard-manager winapi
Last synced: 10 months ago
JSON representation
Clipboard monitoring utility
- Host: GitHub
- URL: https://github.com/doumanash/clipboard-master
- Owner: DoumanAsh
- License: mit
- Created: 2017-03-16T06:32:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-08-10T05:48:58.000Z (over 1 year ago)
- Last Synced: 2024-10-11T14:17:54.180Z (over 1 year ago)
- Topics: clipboard, clipboard-manager, winapi
- Language: Rust
- Homepage: https://crates.io/crates/clipboard-master
- Size: 34.2 KB
- Stars: 43
- Watchers: 4
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clipboard-master

[](https://crates.io/crates/clipboard-master)
[](https://docs.rs/clipboard-master/*/x86_64-pc-windows-msvc/clipboard_master/)
Clipboard monitoring library.
## Supported platforms
- Windows - uses dummy window to receive messages when clipboard changes;
- Linux - uses [x11_clipboard](https://github.com/quininer/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:
```rust
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");
}
```