summaryrefslogtreecommitdiff
path: root/post-screenshot.sh
blob: a798dd165ba5bad5b4e230b3a44cc3684df5b42f (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
#!/usr/bin/env sh

LOCAL_DIR="/home/pacien/medias/pictures/screenshots"
REMOTE_DIR="nginx.berlioz:/var/www/files.pacien.net/screenshots"
BASE_URL="https://files.pacien.net/screenshots"

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" &

scp "$FILE" "$REMOTE_DIR/"

if [ $? -eq 0 ]; then
	SCREENSHOT_URL="$BASE_URL/$FILE_NAME"
	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