blob: 26ba2cf321e1fa9aa418ef459b034a87535a1edd (
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
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/bin/sh
. slib
help() {
cat << EOF
${0}: Wrapper script to take screenshots
options:
-n Black screen
-b Blur
-c Take the current state of the desktop
-h Print this message and exit
EOF
exit 0
}
check_program "slock"
blur=0
set_current_state=0
current_wallpaper="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
while getopts "bcnh" option; do
case "${option}" in
b)
check_program "mogrify" "imagemagick must be installed"
blur=1 ;;
c)
check_program "scrot"
set_current_state=1
;;
n)
slock
exit 0;;
h) help ;;
*) invalid_use -h ;;
esac
done
shift $((OPTIND - 1))
[ "${#}" -eq 0 ] || invalid_use
background="/tmp/$(date '+%b%d::%H%M%S').png"
if [ "$set_current_state" -eq 0 ]; then
# Avoid distorting the wallpaper when calling `mogrify`
cp "${current_wallpaper}" "${background}"
else
scrot -z "${background}"
fi
[ "${blur}" -eq 1 ] && mogrify -blur 0x8 "${background}"
slock -f "${background}"
|