create 'locker'

I just added a pull request to the LARBS repo (https://github.com/LukeSmithxyz/LARBS/pull/126) to add xautolock. It's fairly useful. If you put `xautolock -locker locker` in the i3 config, it'll invoke i3lock after 5 minutes, and if the computer is on battery power, should suspend it 10 minutes after that. If the machine is unlocked (i3lock goes away) or plugged in, it should not invoke sleep.
This commit is contained in:
Elagost 2019-05-01 09:21:59 -07:00 committed by GitHub
parent 29e2cdfb10
commit 03a4c1f20a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
.scripts/tools/locker Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# option to use suckless slock as well - just put "slock" for both variables below
lockprogram="i3lock"
lockcmd="i3lock -e -f -c 120201"
$lockcmd && xset dpms force off
batterystatus=$(cat /sys/class/power_supply/BAT?/status)
if [[ ! -z $(pgrep $lockprogram) && $batterystatus=="Discharging" ]];then
sleep 10m
if [[ ! -z $(pgrep $lockprogram) && $batterystatus=="Discharging" ]];then
systemctl suspend
fi
fi