summaryrefslogtreecommitdiffstats
path: root/screen-locker.sh
blob: 89509785b096d11b4d5ef79178b9f30d73583f2d (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
#!/bin/bash

lock="$HOME/.screen-locker.lck"
exec 9>"${lock}"
if ! flock -n 9; then
	logger "screen locker lock already locked"
	exit
fi

if pidof i3lock &> /dev/null; then exit 1; fi

revert() {
	xset dpms 0 0 0
	logger "unlocking screen"
}
trap revert SIGHUP SIGINT SIGTERM EXIT

# XXX: this seems to be broken so we also have our own loop to do essentially the same
xset +dpms dpms 10 10 10

dpms-loop() {
	exec 9>&-

	sleep 20
	while pidof i3lock &> /dev/null; do
		xset dpms force off
		sleep 30
	done
}

dpms-loop &
loop_pid=$!

logger "locking screen"
i3lock -n -c 000000