-
Notifications
You must be signed in to change notification settings - Fork 2
/
screengrab
executable file
·59 lines (50 loc) · 1.25 KB
/
screengrab
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
#!/bin/bash
# c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t
# vi: set shiftwidth=4 tabstop=4 noexpandtab:
# :indentSize=4:tabSize=4:noTabs=false:
set -o nounset
set -o errexit
set -o pipefail
# shellcheck disable=SC1090
source "$HOME/bin/common.bash"
screenshotdir="$HOME/tmp/grabs"
filename="$(date +%Y%m%d-%H%M%S)"
imagefile="${screenshotdir}/${filename}.png"
swappyimagefile="${screenshotdir}/${filename}-annotated.png"
util="/usr/bin/grimshot save"
mkdir -p $screenshotdir
action="${1:-select}"
notify_debug "Got action '${action}'"
case ${action} in
select)
options="area"
;;
window)
options="active"
;;
screen)
options="output"
;;
full)
options="screen"
;;
*)
errexit "Unknown action ${action}"
;;
esac
grabcommand="${util} ${options} ${imagefile}"
notify_debug "executing ${grabcommand}"
if ifdebug3
then
grabcommand="echo ${grabcommand}"
fi
notify_debug "${grabcommand}"
if ${grabcommand}
then
notify2 "Screenshot ${action} saved to ${imagefile}"
echo -n ${imagefile} | wl-copy
else
errexit "Screenshot ${action} failed"
fi
notify2 "swappy --file ${imagefile} --output-file ${swappyimagefile}"
swappy --file "${imagefile}" --output-file - | tee "${swappyimagefile}" | wl-copy