-
Notifications
You must be signed in to change notification settings - Fork 5
/
shoot
executable file
·52 lines (46 loc) · 1.65 KB
/
shoot
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
#!/usr/bin/env bash
# File: shoot
# Author: Yegor Bayev <baev.egor (at) gmail.com>
# Derived from http://sirupsen.com/static/misc/shoot by Sirupsen @ http://sirupsen.dk
#
# Description: Very simple script to make you
# select a region of your screen, which will be captured, and
# then uploaded. The URL will then be injected into your clipboard.
#
# Dependencies: curl, scrot, xclip, libnotify-bin
#
# License:
#
# Copyright 2013 Yegor Bayev <baev.egor (at) gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see [http://www.gnu.org/licenses/].
CLIENT_ID="9657b96ca0b7f38"
CMDLIST="scrot xclip curl"
for e in $CMDLIST; do
if [ -z "$(which $e)" ]; then
echo "$e not installed, quit."
exit 1
fi
done
SHOTPATH="$HOME/shot.png"
function uploadImage {
curl -H "Authorization: Client-ID $CLIENT_ID" -H "Expect: " -F "image=@$1" https://api.imgur.com/3/image | sed -E 's/.*"link":"([^"]+)".*/\1/' | sed "s|\\\\/|/|g"
}
if scrot -s $SHOTPATH; then
LINK=$(uploadImage $SHOTPATH)
echo $LINK | xclip -selection c
rm $SHOTPATH
notify-send -i go-down "Screenshot on $LINK"
fi
# shoot ends here