-
Notifications
You must be signed in to change notification settings - Fork 0
/
public-screenshot-area.sh
45 lines (39 loc) · 1.15 KB
/
public-screenshot-area.sh
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
#!/bin/bash
DATE=$(date +%s)
FIL_NAME="$(echo "${DATE}${RANDOM}" | sha256sum | (read -ra FILAR; echo "${FILAR[0]}" ))"
FIL_EXTENSION='png'
FIL=${FIL_NAME}.${FIL_EXTENSION}
# shellcheck source=./public-screenshot.env
. ./public-screenshot.env
REMOTEFILE="${REMOTEPATH}/${FIL}"
FILEURL="https://${SRV}${SRVPATH}/${FIL}"
SCREENSHOTCMD=''
COPYCMD=''
case $DESKTOP_SESSION in
'plasmawayland')
SCREENSHOTCMD='spectacle -b -n -r -o'
COPYCMD='wl-copy'
;;
'plasmaX')
SCREENSHOTCMD='spectacle -b -n -r -o'
COPYCMD='xsel -i'
;;
'gnome')
SCREENSHOTCMD='gnome-screenshot -a -f'
COPYCMD='wl-copy'
DENOTIFY="notify-send --expire-time=10000 --app-name=public-screenshot-area.sh New_Screenshot"
;;
'gnomewayX')
SCREENSHOTCMD='gnome-screenshot -a -f'
COPYCMD='xsel -i'
;;
*)
exit 255
;;
esac
cd "${LOCALPATH}" || ( echo -n "Couldn't 'cd' into ${LOCALPATH}" | ${COPYCMD} && exit 1 )
${SCREENSHOTCMD} "${LOCALPATH}/${FIL}"
rsync "${LOCALPATH}/${FIL}" "${SSHSRV}":"${REMOTEFILE}" || ( echo -n "Rsync failed!!" | ${COPYCMD} && exit 1 )
echo -n "${FILEURL}" | ${COPYCMD}
[[ ${DENOTIFY:-} ]] && ${DENOTIFY} "${FILEURL}"
exit 0