-
Notifications
You must be signed in to change notification settings - Fork 0
/
hyprshot
executable file
·95 lines (82 loc) · 2.01 KB
/
hyprshot
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# file
time=`date +%Y-%m-%d-%H-%M-%S`
dir="`xdg-user-dir PICTURES`/Screenshots"
file="Screenshot_${time}.png"
# directory
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
trap notify EXIT
notify () {
notify_cmd_shot="notify-send -u low -i $dir/$file"
echo $notify_cmd_shot
pngcheck ${dir}/"$file" > /dev/null
if [[ -e "$dir/$file" ]]; then
${notify_cmd_shot} "Screenshot Saved." "Screenshot saved in <i>'$dir/$file'</i>"
echo $notify_cmd_shot "Screenshot Saved." "Screenshot saved in <i>'$dir/$file'</i>"
else
# ${notify_cmd_shot} "Screenshot Canceled."
exit
fi
}
# notify and view screenshot
notify_view () {
if [[ $? -eq 0 ]]; then
#${notify_cmd_shot} "Copied to clipboard."
if $($HOME/scripts/sysutil.sh getSound screenshot); then $HOME/scripts/sysutil.sh playSound screen-capture.oga & fi
# viewnior ${dir}/"$file"
# blobdrop -f gui ${dir}/"$file" -b -t &
dragon --icon-only --thumb-size 512 --and-exit ${dir}/"$file" &
( sleep 10 && kill $! ) &
else
# the notifcation too annoying
#${notify_cmd_shot} "Screenshot Canceled."
rm "${dir}/$file"
exit 0
fi
}
# copy screenshot to clipboard
copy_shot () {
tee "${dir}/$file" | wl-copy -t image/png
}
# countdown
countdown () {
for sec in `seq $1 -1 1`; do
dunstify -t 1000 -h string:x-dunst-stack-tag:screenshottimer -i /usr/share/archcraft/icons/dunst/timer.png "Taking shot in : $sec"
sleep 1
done
}
# take shots
shotnow () {
grim - | copy_shot
notify_view
}
shot5 () {
countdown '5'
sleep 1 && grim - | copy_shot
notify_view
}
shot10 () {
countdown '10'
sleep 1 grim - | copy_shot
notify_view
}
shotarea () {
g=$(slurp -d) || exit 1
grim -g "$g" - | copy_shot
notify_view
}
# execute
if [[ "$1" == "--now" ]]; then
shotnow
elif [[ "$1" == "--in5" ]]; then
shot5
elif [[ "$1" == "--in10" ]]; then
shot10
elif [[ "$1" == "--area" ]]; then
shotarea
else
echo -e "Available Options : --now --in5 --in10 --area"
fi
exit 0