This commit is contained in:
JMARyA 2021-05-14 10:59:35 +02:00
commit 956746d3e3
5 changed files with 104 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

71
Cargo.lock generated Normal file
View file

@ -0,0 +1,71 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "block"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "clipboard_macos"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145a7f9e9b89453bc0a5e32d166456405d389cea5b578f57f1274b1397588a95"
dependencies = [
"objc",
"objc-foundation",
"objc_id",
]
[[package]]
name = "clipwatch"
version = "0.1.0"
dependencies = [
"clipboard_macos",
]
[[package]]
name = "libc"
version = "0.2.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e"
[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]
[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]
[[package]]
name = "objc-foundation"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
dependencies = [
"block",
"objc",
"objc_id",
]
[[package]]
name = "objc_id"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b"
dependencies = [
"objc",
]

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "clipwatch"
version = "0.1.0"
authors = ["JMARyA <jmarya0@icloud.com>"]
edition = "2018"
[dependencies]
clipboard_macos = "0.1.0"

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# ClipWatch
Really simple tool to monitor and print clipboard content to stdout

21
src/main.rs Normal file
View file

@ -0,0 +1,21 @@
use clipboard_macos::*;
use std::{thread, time};
fn main() {
let c = Clipboard::new().unwrap();
let mut cstr = String::new();
let ten_millis = time::Duration::from_millis(10);
loop {
let nstr = c.read();
if nstr.is_err() {
continue;
}
let nstr = nstr.unwrap();
if nstr != cstr {
println!("{}", nstr);
cstr = nstr;
}
thread::sleep(ten_millis);
}
}