-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshot-upload.sh
executable file
·44 lines (38 loc) · 1.17 KB
/
screenshot-upload.sh
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
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
API_KEY=`head -n1 ${DIR}/screenshot-api-key`
TYPE=jpg #png, jpg, gif, etc. | if you change this, be sure to change the quality
QUALITY=90 #image quality
FILE="$HOME/Desktop/screenshot-`date '+%Y-%m-%d-%N'`.${TYPE}"
case "$1" in
-s|--selection)
OPTIONS="-s -b -q ${QUALITY}"
;;
-a|--all)
OPTIONS="-q ${QUALITY}"
;;
*)
echo "Usage: ${0} <-a/--all|-s/--selection> [-n/--noupload]"
exit 1
esac
scrot ${OPTIONS} "${FILE}"
case "$2" in
-n|--noupload)
exit 0
;;
*)
#curl -# -F "image"=@"${FILE}" -F "key"="${API_KEY}" http://api.imgur.com/2/upload.xml |\
# grep -Eo '<[a-z_]+>http[^<]+' |\
# sed 's/^<.\|_./\U&/g;s/_/ /;s/<\(.*\)>/\x1B[0;34m\1:\x1B[0m /'
#TEXT=$(curl -F "image"=@"${FILE}" -F "key"="${API_KEY}" http://api.imgur.com/2/upload.xml | \
# grep -Eo '<[a-z_]+>http[^<]+' | \
# sed 's/^<.\|_./\U&/g;s/_/ /;s/<\(.*\)>/\1:\ /');
LINK=$(curl -\# -F "image"=@"${FILE}" -F "key"="${API_KEY}" http://api.imgur.com/2/upload.xml | \
grep -Eo '<[a-z_]+>http[^<]+' | \
grep original | \
sed 's/^<.*>//' );
echo -n $LINK | xclip -selection clipboard
rm "${FILE}"
exit 0
;;
esac