mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-09 07:24:03 +08:00
25 lines
616 B
Swift
25 lines
616 B
Swift
//
|
|
// main.swift
|
|
// clipboard-event
|
|
//
|
|
// Created by Joonhee Lee on 2021/01/30.
|
|
//
|
|
|
|
import Foundation
|
|
import Cocoa
|
|
|
|
let pasteboard: NSPasteboard = NSPasteboard.general
|
|
var count: Int = pasteboard.changeCount
|
|
var saved: String = pasteboard.string(forType: .string) ?? "null"
|
|
|
|
repeat{
|
|
usleep(500000)
|
|
if(count < pasteboard.changeCount && saved != pasteboard.string(forType: .string)){
|
|
usleep(100000)
|
|
count = pasteboard.changeCount
|
|
saved = pasteboard.string(forType: .string) ?? "null"
|
|
print("CLIPBOARD_CHANGE")
|
|
fflush(stdout)
|
|
}
|
|
}while true
|