forked from XorFish/i3-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi3lock-wrapper
executable file
·94 lines (79 loc) · 2.39 KB
/
i3lock-wrapper
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
#!/bin/bash
set -e
script_name=$(basename $0)
params=$(getopt -o vnbdup:h -l version,nofork,beep,dpms,no-unlock-indicator,pointer:,help -n "$script_name" -- "$@")
eval set -- "$params"
# exit on bad argyments
if [ $? -ne 0 ]; then
exit 1
fi
usage () {
cat <<EOF
A wrapper around i3lock that sets a blurred screenshot
as a background image for the screen saver.
Usage: $script_name [options]
-v, --version version of the i3lock.
-n, --nofork don't fork i3lock after start.
-b, --beep enable beeping.
-d, --dpms enable turning off the screen with DPMS.
-u, --no-unlock-indicator disable the unlock indicator.
-p win|default,
--pointer=win|default do not hide the mouse pointer on default
or the current position of the mouse pointer.
Please note, that all the options are being passed directly to i3lock.
See more details via man i3lock.
EOF
}
arg_test () {
# Filter out arguments that are invalid
while true; do
case "$1" in
-v|--version)
i3lock -v
exit
;;
-n|--nofork)
shift;;
-b|--beep)
shift;;
-d|--dpms)
shift;;
-u|--no-unlock-indicator)
shift;;
-p|--pointer)
shift
case "$1" in
win|default)
shift;;
*)
echo "$script_name: invalid option \"$1\" for argument -p" >&2
exit 1
;;
esac
;;
-h|--help)
usage
exit
;;
--)
shift
break ;;
*)
echo "$script_name: invalid argument \"$1\"" >&2
exit 1
;;
esac
done
if [ $# -ne 0 ]; then
echo "$script_name: invalid arguments \"$@\""
exit 1
fi
}
arg_test $@
file1=$(mktemp --tmpdir i3lock-wrapper-XXXXXXXXXX.png)
file2=$(mktemp --tmpdir i3lock-wrapper-XXXXXXXXXX.png)
scrot -d0 "$file1"
convert "$file1" -blur 0x3 "$file2"
# drop the last "--" introduced by getopt
i3lock -i "$file2" ${@:1:($#-1)}
trap "rm '$file1' '$file2'" EXIT