-
Notifications
You must be signed in to change notification settings - Fork 0
/
shot
executable file
·49 lines (43 loc) · 930 Bytes
/
shot
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
#!/bin/sh
# Make screenshot.
# file used for intermediate screenshot storage
tmpfile=~/.cache/screen.png
# default option values
area=select
save=toclip
# make a screenshot
screenshot() {
rm -f "$tmpfile" # just in case
case $area in
full) maim "$tmpfile" ;;
select) # make sure that touchpad is enabled
tp=$(tp state)
[ "$tp" = off ] && tp toggle
maim -s "$tmpfile"
[ "$tp" = off ] && tp toggle
esac
}
# save image
imgaction() {
[ -f "$tmpfile" ] || return # screenshot failed
case $save in
toclip) xclip -i -select clipboad -t image/png "$tmpfile" ;;
tofile) cp "$tmpfile" "$HOME/$(date +'%d-%m-%y_%H:%M:%S').png" ;;
open) nsxiv "$tmpfile"
esac
rm "$tmpfile"
}
# parse options
while getopts ':Fof' opt; do
case $opt in
F) area=full ;;
o) save=open ;;
f) save=tofile ;;
*)
echo "usage: ${0##*/} [-Fof]"
exit 1
esac
done
# make a screenshot and do the thing
screenshot
imgaction