-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshot2web
executable file
·48 lines (39 loc) · 1.51 KB
/
screenshot2web
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
#!/bin/sh
# Screen grabber/auto paster
#
# Lets you select an area of the screen with the mouse, then automatically
# pastes a screenshot of that area to a public server and puts the URL in the
# clipboard for you. Can also open the URL in a browser and automatically
# middle-click paste the URL as soon as it's available if you want.
#
# Requires imagemagick, curl and xclip.
#
# Configure the below as appropriate for you.
# Paste site. Needs to return a redirect URI to view the file when we post to it
PASTESITE=https://f.dollyfish.net.nz
# Which web browser to open the paste in. Leave blank/comment out to do nothing
BROWSER=google-chrome
# Whether to automatically simulate a middle-click paste (needs xautomation)
AUTOPASTE=
# Whether to pop up a notification saying the URL has been retrieved (needs
# libnotify-bin)
NOTIFY=1
# No more configuration beyond this point
set -e
SS_DIR=/tmp
SS_FILE=screenshot.png
rm -f $SS_DIR/$SS_FILE
flameshot gui -p $SS_DIR
while events=$(inotifywait -e close_write -t 600 $SS_DIR); do
filename=$(echo "$events" | cut -f 3 -d ' ')
if [ "$filename" = $SS_FILE ]; then
url=$(curl -s -w '%{redirect_url}\n' -F "file=@$SS_DIR/$SS_FILE;type=image/png" $PASTESITE)
url=https${url#*http}
echo $url | xclip
[ -n "$BROWSER" ] && $BROWSER $url
[ $AUTOPASTE ] && xte 'mouseclick 2'
[ $NOTIFY ] && notify-send -c presence -i /usr/share/icons/hicolor/32x32/apps/checkbox.png "Image URL" "$url"
rm $SS_DIR/$SS_FILE
exit 0
fi
done