3 # Copyright (C) 2016 Richard Burke, ISC licensed
11 vc_fatal
"`basename $0` [--selection sel] [--usable|--copy|--paste]"
14 vc_determine_command
() {
15 if [ -n "$WAYLAND_DISPLAY" ]; then
16 for c
in wl-copy wl-paste
; do
17 if type "$c" >/dev
/null
2>&1; then
24 if [ -n "$DISPLAY" ]; then
25 for c
in xclip xsel
; do
26 if type "$c" >/dev
/null
2>&1; then
33 if [ "$sel" = "primary" ]; then
34 vc_fatal
"clipboard primary selection is not supported on your platform"
37 if type pbcopy
>/dev
/null
2>&1; then
42 if [ -c /dev
/clipboard
]; then
51 if vc_determine_command
>/dev
/null
2>&1; then
59 COPY_CMD
="`vc_determine_command 2>/dev/null`"
61 if [ $?
-ne 0 ] ||
[ -z "$COPY_CMD" ]; then
62 vc_fatal
'System clipboard not supported'
71 PASTE_CMD
="`vc_determine_command 2>/dev/null`"
73 if [ $?
-ne 0 ] ||
[ -z "$PASTE_CMD" ]; then
74 vc_fatal
'System clipboard not supported'
82 vc_wlclipboard_copy
() {
83 if [ "$sel" = "primary" ]; then
84 wl-copy
--primary -t TEXT
90 vc_wlclipboard_paste
() {
91 if [ "$sel" = "primary" ]; then
92 wl-paste
--primary -t text
107 xclip
-selection "$sel" -i >/dev
/null
2>&1
111 xclip
-selection "$sel" -o
130 while [ $# -gt 0 ]; do
132 --usable) fn
=vc_usable
;;
134 --paste) fn
=vc_paste
;;
135 --selection) shift; sel
="$1";;
141 sel
=${sel:-"clipboard"} $fn