Skip to content

About

Cross-platform clipboard watcher

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

go-clipboard

Cross-platform clipboard watcher

  • X11: Event-driven via the XFIXES extension (no polling)
  • Mac: NSPasteboard polling, cgo
  • Android/Termux: termux-clipboard-get polling, watch-only

Library

cb, err := clipboard.Open(ctx)
for text := range cb.Changes() { ... } // changes made by other apps
cb.Set("hello")                        // take the clipboard over

Open picks a backend for the session. Under Termux an X server (termux-x11) and the Android system clipboard are both live and are two different clipboards, so name the one you want:

cb, err := clipboard.OpenBackend(ctx, "termux") // or "x11", "" for auto

The termux backend only watches; Set returns clipboard.ErrReadOnly.

Changes never reports values written with Set on the same Clipboard, so mirroring a remote clipboard into Set cannot loop back into itself. There is also clipboard.Watch(ctx) (<-chan string, error) if you only need change notification.

CLI: clipsync

Sync clipboard between machines over TCP. One side runs serve, the others sync:

  • sync clipboard on mac / linux / android
  • many peers can connect to one server; it relays between them, so A and C stay in sync through B without connecting to each other

server

clipsync serve :4444

client

clipsync sync 192.168.64.1:4444

Both accept -backend=name. On Android, -backend=termux feeds the Android system clipboard into the mesh; it never writes back, so received values are logged as dropped.

About

Cross-platform clipboard watcher

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages