-
Notifications
You must be signed in to change notification settings - Fork 0
/
dm-shot.sh
executable file
·78 lines (72 loc) · 1.22 KB
/
dm-shot.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# _ _ ___
# | || | __| H
# | __ | _| A
# |_||_|___| P
#
#
#if [[ -z "$1" ]]; then
#themon=''
#else
#themon="-m $1"
#fi
# Variables {{{
dmenu="dmenu \
-i \
-l 20 \
${@} \
"
script_name="ScreenShot"
#script_name=$(echo $0 | awk -F '/' '{print $NF;}')
# }}}
scrot="scrot"
directory="$HOME/screen/shots"
execarg="mv \$f ${directory}/ & nsxiv ${directory}/\$f & echo ${directory}/\$f | xclip -selection c "
quality="-q 60"
# sent notification {{{
notify() {
case $2 in
1)
mode=low
;;
2)
mode=normal
;;
3)
mode=critical
;;
*)
mode=normal
;;
esac
notify-send -u $mode -a ${script_name} -i accessories-screenshot "${1}"
}
# }}}
# main {{{
choice=$(printf '%s\n' \
"whole screen" "active window" "area" "quit" \
| $dmenu -p ${script_name} \
| awk '{print $1}')
if [ ! -d "$HOME/screen/shots" ]; then
mkdir -p $HOME/screen/shots
fi
case ${choice} in
quit)
exit 0
;;
whole)
scrot 'shots-%y%m%d_%H%M%S_$wx$h.png' $quality -e "$execarg"
;;
active)
scrot -u 'shots-%y%m%d_%H%M%S_$wx$h.png' $quality -e "$execarg"
;;
area)
scrot -s 'shots-%y%m%d_%H%M%S_$wx$h.png' $quality -e "$execarg"
;;
*)
notify "Shot canceled." 1
exit 1
;;
esac
notify "Screenshot taken."
# }}}