golang-design / clipboard

📋 cross-platform clipboard package that supports accessing text and image in Go (macOS/Linux/Windows/Android/iOS)
https://golang.design/x/clipboard
MIT License
579 stars 64 forks source link

Exit directly after copying #15

Closed TaceyWong closed 2 years ago

TaceyWong commented 2 years ago

if :

clipboard.Write(clipboard.FmtText, []byte("hello world"))
exit()

or

clipboard.Write(clipboard.FmtImage, content)
exit()

there will be nothing in clipboard else:

<-clipboard.Write(clipboard.FmtText, []byte(imagePath))

clipboard is ok,but program is blocked untill something new is copied into clipboad .


ubuntu20.04

changkun commented 2 years ago

This is an expected behavior on Linux systems.

TaceyWong commented 2 years ago

thx for your reply . Maybe I need adjust the flow of my program.

after copying,add a time sleep,it will be ok.

Is there a sync-way to execute copy-work,or, an async-way but can be notified in select style after copy-work completed.

changkun commented 2 years ago

This is how X11 clipboard systems should work. Clipboard writers must stay live in order to serve the copy requests from others until the next writer writes new content.

The application should either stay to not exit or run in the background. See gclip as a clipboard example.

Close as this is as being said an expected behavior in X11 systems.