Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle clipboard change event? #78

Open
bit-ranger opened this issue Sep 3, 2022 · 5 comments
Open

Handle clipboard change event? #78

bit-ranger opened this issue Sep 3, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@bit-ranger
Copy link

bit-ranger commented Sep 3, 2022

Is there any way to handle clipboard change event?

@bit-ranger bit-ranger changed the title Is there any way to handle clipboard change event? Handle clipboard change event? Sep 3, 2022
@complexspaces
Copy link
Collaborator

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.

@0-don
Copy link

0-don commented Jun 8, 2023

its posible https://crates.io/crates/clipboard-master

@complexspaces complexspaces added the enhancement New feature or request label Feb 13, 2024
@huangganggui
Copy link

@complexspaces Can i start a thread monitor the clipboard.get_text() change or not?

@complexspaces
Copy link
Collaborator

@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.

@huangganggui
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants