summaryrefslogtreecommitdiff
path: root/post-screenshot.sh
blob: 759266539049e3c5493ebc95f8a36c641327df99 (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/pictures/screenshots"
REMOTE_DIR="nas.lsn:/home/pacien/www/net.pacien.files/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