nix-setup/sl.script.nix
2024-10-28 14:16:58 +01:00

27 lines
448 B
Nix

with import <nixpkgs> {};
pkgs.writeShellScriptBin "sl" ''
#!/bin/sh
killall xss-lock i3lock
sleep 0.1
xss-lock --transfer-sleep-lock -- i3lock --nofork &
PID=$!
lastdate="$(date +%s)"
ok=0
sudo systemctl suspend
exit # nofprint
while kill -0 $PID ; do
if [ "$(($(date +%s) - $lastdate))" > 5 ] && [ "$ok" = 0 ] ; then
sudo systemctl restart fprintd
ok=1
sleep 2
fi
fprintd-verify && kill $PID
sleep 2
done
''