Created
April 4, 2020 08:57
-
-
Save Defelo/91e78cfac3fcb7474b4d009ed1f9872f to your computer and use it in GitHub Desktop.
X11 Clipboard Sync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
[[ $# -lt 2 ]] && echo "usage: $0 <first display> <second display>" && exit 1 | |
clipread() { | |
xclip -selection clip -r -o -display $1 2> /dev/null | |
} | |
clipwrite() { | |
xclip -selection clip -r -i -display $1 | |
} | |
clipboard= | |
update() { | |
content=$(clipread $1) | |
if [[ "$content" != "$clipboard" ]] | |
then | |
clipboard=$content | |
clipwrite $2 <<< "$content" | |
fi | |
} | |
while true | |
do | |
update $1 $2 | |
sleep .1 | |
update $2 $1 | |
sleep .1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment