blob: a07022dbbf4deec1289b1c8e42391e0287a8cec6 (
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
60
61
62
63
64
65
|
#!/usr/bin/env sh
set -x -e
trap_notifications() {
pkill -u "$USER" -USR1 dunst
}
untrap_notifications() {
pkill -u "$USER" -USR2 dunst
}
lock() {
lock_image="$1"
trap_notifications
i3lock -n -i "$lock_image" \
--inside-color="00000000" \
--ring-color="00000033" \
--separator-color="00000000" \
--insidever-color="00000000" \
--insidewrong-color="ff000033" \
--keyhl-color="ffffff77" \
--bshl-color="ffffff77" \
--ringver-color="00000000" \
--ringwrong-color="00000000" \
--greeter-color="00000000" \
--line-color="00000000" \
--verif-text="" \
--wrong-text="" \
--noinput-text="" \
--pass-media-keys \
--pass-screen-keys \
--pass-volume-keys \
--pass-power-keys
untrap_notifications
}
create_lock_image() {
image=$(mktemp --suffix=.png)
command -- import -silent -window root "$image"
primary_monitor_info=$(xrandr | grep primary | awk '{print $4}')
if [[ $primary_monitor_info == *+* ]]; then
resolution=$(echo $primary_monitor_info | cut -d'+' -f1)
offset_x=$(echo $primary_monitor_info | cut -d'+' -f2)
offset_y=$(echo $primary_monitor_info | cut -d'+' -f3)
else
resolution=$(xrandr | grep '*' | awk '{print $1}')
offset_x=0
offset_y=0
fi
width=$(echo $resolution | cut -d'x' -f1)
height=$(echo $resolution | cut -d'x' -f2)
center_x=$(($offset_x + $width / 2))
center_y=$(($offset_y + $height / 2))
convert "$image" -filter Gaussian -resize 20% -define "filter:sigma=4.5" -resize 500.5% \
"$HOME/img/lib/lock.png" -gravity NorthWest -geometry +${center_x}+${center_y} -composite "$image"
echo "$image"
}
command -v notify-send >/dev/null && notify-send "Locking..."
image=$(create_lock_image)
lock "$image"
rm "$image"
|