-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path_clipboard.bash
More file actions
40 lines (34 loc) · 806 Bytes
/
Copy path_clipboard.bash
File metadata and controls
40 lines (34 loc) · 806 Bytes
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
check_clipboard() {
local cmd
if is_wayland; then
requires wl-paste
cmd="wl-paste -l"
else
requires xclip
cmd="xclip -selection clipboard -o -t TARGETS"
fi
$cmd | grep image > /dev/null
}
from_clipboard() {
if is_wayland; then wl-paste -t image/png
else
xclip -selection clipboard -t image/png -o
fi
}
to_clipboard() {
local mime="text/plain"
if [ "${1:-text}" = "image" ]; then
is_jpeg && mime="image/jpeg" || mime="image/png"
fi
if is_wayland; then
requires wl-copy
wl-copy -t $mime
else
requires xclip
if [ "${mime}" == "text/plain" ]; then
xclip -selection clipboard
else
xclip -selection clipboard -t "${mime}"
fi
fi
}