atotto / clipboard

clipboard for golang
BSD 3-Clause "New" or "Revised" License
1.24k stars 143 forks source link

Add support for clearing the clipboard #23

Open renatoathaydes opened 6 years ago

renatoathaydes commented 6 years ago

Hi! I've used this little lib in one of my projects and it works great! Thanks for creating this :)

But I would like to make a feature request: add support for clearing the clipboard.

For example, in Linux with xsel you just need to call xsel -c.

Not sure about Mac/Windows, but hope it's easy to do as well.

My usecase is that I want to copy sensitive information to the clipboard for a short period of time.

renatoathaydes commented 6 years ago

I don't know if that's possible, but do you know if there's a way to just clear the clipboard everytime the user pastes something? Password Managers do that, I wonder how...

dmitshur commented 6 years ago

I'm not sure either, but what happens if you place the empty string into the clipboard?

renatoathaydes commented 6 years ago

Pasting the empty string and not pasting anything is not really the same, but it does solve my problem :)

I just need to remove sensitive data from the clipboard... looks like xsel never persists anything , so just writing an empty String is fine... but I think the Mac version keeps a list?