Elagost 03a4c1f20a
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.
2019-05-01 09:21:59 -07:00

13 lines
430 B
Bash

#!/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