openkubsd/bin/copy_clipboard.sh
2023-06-21 19:18:25 +02:00

32 lines
935 B
Bash
Executable File

#!/bin/sh
SOURCE=$(zenity \
--list --radiolist --width=600 \
--title="Copy clipboard between programs" \
--text="Choose a clipboard to copy from" \
--print-column=4 \
--column="From" --column="PID" --column="Kube name" --column="Local X server" --column="Program running" \
TRUE 1 $(hostname) 0.0 Host \
$(awk '{ print "FALSE "$0 }' /tmp/kubes.txt))
if [ -z "$SOURCE" ]
then
exit 0
fi
DESTINATION=$(zenity \
--list --radiolist --width=600 \
--title="Copy clipboard between programs" \
--text="Choose a destination clipboard" \
--print-column=4 \
--column="To" --column="PID" --column="Kube name" --column="Local X server" --column="Program running" \
TRUE 1 $(hostname) 0.0 Host \
$(awk -v orig="${SOURCE}" '$3!=orig { print "FALSE "$0 }' /tmp/kubes.txt))
if [ -z "$DESTINATION" ]
then
exit 0
fi
env DISPLAY=":$SOURCE" xclip -o - | env DISPLAY=":$DESTINATION" xclip