uni icon indicating copy to clipboard operation
uni copied to clipboard

Allow copying to clipboard

Open arp242 opened this issue 4 years ago • 3 comments

From HN comment https://news.ycombinator.com/item?id=21780608

echo -n "$selected_symbol" | xclip -i

And then fake a middle click to insert in the current application:

xdotool click 2o

Also maybe send as direct input (xdotool can do this, but is apparently not reliable across all apps/characters).

Can also link to libX11, but this requires cgo and makes builds harder.

arp242 avatar Jan 01 '21 11:01 arp242

How about https://godoc.org/github.com/BurntSushi/xgb or https://godoc.org/github.com/BurntSushi/xgbutil? Both are pure Go.

skuzzymiglet avatar Jan 01 '21 18:01 skuzzymiglet

Yeah, I think I looked at that actually; I probably just didn't feel like working on it because the dmenu integration works well enough for me haha

arp242 avatar Jan 02 '21 18:01 arp242

https://github.com/golang-design/clipboard is nice, and cross-platform.

The big problem with this is how the X clipboard works. When you "copy" something nothing is actually copied; the application just takes ownership of the clipboard, and on paste X asks the application which text to send. This is a well-known annoyance: quit an application and if you had something copied in there then it's lost.

Tools like xclip work around this by forking and staying active, so that print foo | xclip doesn't block your shell. Forking in Go seems rather hard though, and not something that's easily possible.

Running xclip also doesn't really work, since it will wait for xclip to finish, although that may be solvable.

And need to look at this whole wayland thing, too.

Meh...

arp242 avatar Apr 02 '22 13:04 arp242