feat: turn off screen when locked

This commit is contained in:
Klesh Wong 2022-10-23 22:33:39 +08:00
parent db0c1ecd0c
commit 81901c3d0f
2 changed files with 28 additions and 1 deletions

27
bin/afk.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
screenoff(){
sleep 3
xset dpms force off
}
if mpc status | grep -F '[playing]'; then
mpc pause
RESTORE_MPD=1
fi
if command -v bluetoothctl >/dev/null; then
RESTORE_BLU=$(bluetoothctl show | grep -F "Powered: yes")
fi
if [ -n "$LOCKER" ]; then
screenoff &
$LOCKER
else
slock
fi
if [ "$RESTORE_MPD" = 1 ]; then
mpc play
fi
if [ -n "$RESTORE_BLU" ]; then
bluetoothctl power on
fi

View File

@ -348,7 +348,7 @@ awful.screen.connect_for_each_screen(function(s)
onlogout = awful.quit,
onpoweroff = function() awful.spawn.with_shell("loginctl poweroff") end,
onreboot = function() awful.spawn.with_shell("loginctl reboot") end,
onlock = function() awful.spawn.with_shell("loginctl lock-session") end,
onlock = function() awful.spawn.with_shell("afk.sh") end,
onsuspend = function() awful.spawn.with_shell("loginctl suspend") end,
},
},