parent
59c802383c
commit
a38aaf57ef
@ -1,19 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# I run this in crontab every five minutes
|
|
||||||
|
|
||||||
warning=10
|
warning=10
|
||||||
error=5
|
error=5
|
||||||
|
|
||||||
battery_percent="$(cat /sys/class/power_supply/BAT0/capacity)"
|
while true; do
|
||||||
|
battery_status=$(cat /sys/class/power_supply/BAT0/status)
|
||||||
if [[ ${battery_percent} -gt ${warning} ]]; then
|
battery_percent=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
exit 0
|
if [[ "${battery_status}" == "Discharging" ]] && [[ ${battery_percent} -lt ${warning} ]]; then
|
||||||
fi
|
mtype="warning"
|
||||||
if [[ ${battery_percent} -lt ${warning} ]]; then
|
if [[ ${battery_percent} -lt ${error} ]]; then
|
||||||
mtype="warning"
|
mtype="error"
|
||||||
fi
|
fi
|
||||||
if [[ ${battery_percent} -lt ${error} ]]; then
|
/usr/bin/swaynag -o eDP-1 -s "Dismiss" -e bottom -t ${mtype} -m "${mtype^^}: Battery at ${battery_percent}%"
|
||||||
mtype="error"
|
fi
|
||||||
fi
|
sleep 60
|
||||||
swaynag -s "Dismiss" -e bottom -t ${mtype} -m "WARNING: Battery at ${battery_percent}%"
|
done
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in new issue