summaryrefslogtreecommitdiff
path: root/post-screenshot.sh
blob: ff2507deda3d899986ca7a198a535054e9d6a52b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env sh

LOCAL_DIR="$HOME/medias/pictures/screenshots"
REMOTE_SERVICE_URL="https://paste.gnugen.ch"
PASTE_EXPIRATION="1d"

TS=$(date +"%s")
RAND=$(shuf -i 1000-9999 -n 1)

FILE_NAME="$TS$RAND.png"
FILE="$LOCAL_DIR/$FILE_NAME"

scrot "$FILE" -s
viewnior "$FILE" &

SCREENSHOT_URL=$(curl -F "file=@$FILE;type=image/png" -F "expire=$PASTE_EXPIRATION" -H "Expect:" "$REMOTE_SERVICE_URL")

if [ $? -eq 0 ]; then
	notify-send --category=transfer.complete "Screenshot upload complete." "$SCREENSHOT_URL"
	echo -n "$SCREENSHOT_URL" | xclip -i
else
	notify-send --category=transfer.error "Screenshot upload failed."
fi