-
Notifications
You must be signed in to change notification settings - Fork 13
/
pclip
executable file
·59 lines (53 loc) · 1.43 KB
/
pclip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# gclip -- get text into clipboard
# pclip -- put/paste text from clipboard
# psel -- put/paste text from primary selection
#
# (The names are a little backwards, but that's how the UnxUtils gclip.exe worked.)
. lib.bash || exit
case ${0##*/} in
gclip)
if [ "$WAYLAND_DISPLAY" ] && have wl-copy; then
cmd="wl-copy"
elif [ "$DISPLAY" ] && have xsel; then
cmd="xsel -i -b -l /dev/null"
elif [ "$DISPLAY" ] && have xclip; then
cmd="xclip -in -selection clipboard"
elif [ "$WAYLAND_DISPLAY" ] || [ "$DISPLAY" ]; then
vdie "no clipboard tools installed"
else
vdie "clipboard not available"
fi;;
pclip)
if [ "$WAYLAND_DISPLAY" ] && have wl-paste; then
cmd="wl-paste"
elif [ "$DISPLAY" ] && have xsel; then
cmd="xsel -o -b"
elif [ "$DISPLAY" ] && have xclip; then
cmd="xclip -out -selection clipboard"
elif [ "$WAYLAND_DISPLAY" ] || [ "$DISPLAY" ]; then
vdie "no clipboard tools installed"
else
vdie "clipboard not available"
fi;;
psel)
if [ "$WAYLAND_DISPLAY" ] && have wl-paste; then
cmd="wl-paste -p"
elif [ "$DISPLAY" ] && have xsel; then
cmd="xsel -o -p"
elif [ "$DISPLAY" ] && have xclip; then
cmd="xclip -out -selection primary"
elif [ "$WAYLAND_DISPLAY" ] || [ "$DISPLAY" ]; then
vdie "no clipboard tools installed"
else
vdie "clipboard not available"
fi;;
*)
vmsg "bad invocation" >&2
exit 2;;
esac
if [ "$1" = -q ]; then
echo "$cmd"
else
$cmd
fi