blob: 2df9049451887b8c506180bf9c8e3b8f7f63c755 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/sh
printusage() {
cat << HELPDOC
Usage: $(basename "$0") [-cx]
OPTIONS:
-c\tInteractively crop screenshot
-x\tCopy screenshot to clipboard with xclip rather than saving it
HELPDOC
}
# Scrot and xclip opts
fmt=$(date '+%m-%d-%4Y_%I:%M:%S_%p.png') # Scrot will output ..._000.png in case of rapid screenshots
tmppath=/tmp
savpath=~/pics/screenshots
normopt=''
cropopt='--select --freeze'
normexp='echo $f'
xclipexp='xclip -selection clipboard -target image/png -i $f && echo $f'
# Notify-send opts
notifyopts="--expire-time 4000 --urgency low"
normsumm="Screenshot Saved!"
xclipsumm="Screenshot Copied!"
normbody="Screenshot saved as \"$fmt\""
xclipbody="Screenshot copied to clipboard"
# Default opts
opt=$normopt
path=$savpath
exp=$normexp
summ=$normsumm
body=$normbody
while getopts "cxh" arg; do
case "$arg" in
c) opt=$cropopt ;;
x) path=$tmppath; exp=$xclipexp; summ=$xclipsumm; body=$xclipbody ;;
h|*) printusage && exit ;;
esac
done
mkdir -p "$path"
scrot $opt "$path/$fmt" --exec "$exp" \
&& notify-send $notifyopts -i "$path/$fmt" "$summ" "$body" \
|| notify-send $notifyopts "Screenshot Failed!"
|