arboard
arboard copied to clipboard
Handle clipboard change event?
Is there any way to handle clipboard change event?
Hey there, @bit-ranger. AFAIK, clipboard change events are a feature of window managers and not raw clipboard accesses. Windows, for example, has AddClipboardFormatListener
that can fire WM
events for you, but I don't know if its usable in the context of a CLI application off the top of my head.
its posible https://crates.io/crates/clipboard-master
@complexspaces Can i start a thread monitor the clipboard.get_text()
change or not?
@huangganggui No, that won't work like you want. get_text()
does not block waiting for changes, it will either return the current clipboard contents or an error if nothing is available.
In theory: you could read the current clipboard value, poll the clipboard every second in a thread, and see if the value has changed but that's pretty inefficient.
@complexspaces Nice! I will try poll the clipboard every 0.1s in a thread. In my case, efficiency maybe not such important. Thanks a lot.