Two way sync between the clipboard and a file.
If the system clipboard is updated (e.g. by pressing ctrl+c
), the changes are written to clipboard.txt
.
If the clipboard.txt
file is updated (e.g. by echo 123 > clipboard.txt
) this change is written to the system clipboard.
I am using this script to have a shared clipboard between host and a virtual machine. Both machines need to have access to the clipboard.txt
file. This can for example be accomplished by samba or SMB or any other file sync software.
Build on Linux for Linux:
go build
Build on Linux for Windows:
GOOS=windows GOARCH=amd64 go build
- Configure and enable samba server in Linux
- Mount samba share in Windows
- Run the Linux binary on Linux, the Windows binary on Windows (see command below)
- Clipboard sharing should now work
# e.g.
clipboard-monitor.exe \\192.168.0.1\clipboard-share\
clipboard-monitor ~/clipboard-share
- This is most probably not very secure and should be improved
- notify doesn't work from Linux to Windows (only the other way around). Thus there is a fallback to poll the file very 5 seconds