summaryrefslogtreecommitdiff
path: root/scripts/gui/sclip
blob: ac664cc45484b931fc506d7af66ca43ccf7b3e24 (plain)
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
#!/bin/sh

. slib

help() {
cat << EOF
${0}: Copy the content of filepath into clipboard
options:
 -h              Print this message and exit
EOF

exit 0
}

check_program "xclip"

[ "${#}" != 1 ] && invalid_use
[ "${1}" = "-h" ] && help


FILE="${1}"

[ ! -f "${FILE}" ] && err "${FILE} not found"

MIME_TYPE=$(file --mime-type -b "${FILE}")

run "xclip -selection clipboard -t ${MIME_TYPE} -i ${FILE}"