ref: a55e738c145b44f13d1d6be38c768a655428e54c dotfiles/overlay/bin/locknow -rwxr-xr-x 506 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash

# lock the screen now

if [ "$(uname)" = "OpenBSD" ] ; then
	pkill -USR1 xidle
else
	~/bin/restore-sanity
	sleep "0.1"
	if xautolock -locknow 2>&1 | grep -q "Could not locate a running xautolock" ; then
		echo "restarting xautolock... "
		sleep 1
		if [ "$(ps aux | awk '$11 ~ /^xautolock/ {print($2)}' | wc -l)" -gt 0 ] ; then
			kill "$(ps aux | awk '$11 ~ /^xautolock/ {print($2)}')"
		fi
		xautolock -time $config -locker "xset dpms force off && xtrlock -b" &
		disown
		$0
	fi
fi