arp242 / uni

Query the Unicode database from the commandline, with good support for emojis
MIT License
802 stars 19 forks source link

Allow copying to clipboard #22

Open arp242 opened 3 years ago

arp242 commented 3 years ago

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.

skuzzymiglet commented 3 years ago

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

arp242 commented 3 years ago

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 commented 2 years ago

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