zenUtils/batAlarm.sh

30 lines
601 B
Bash
Raw Normal View History

#!/bin/sh
# Just a background script to tell you when your battery's low if you don't
# have a panel.
2024-09-26 04:15:43 +00:00
# Iris Lightshard <nilix@nilfm.cc>
# MIT License
2024-10-17 16:03:04 +00:00
warn=30
crit=20
dismissed=0
while true; do
charge=$(cat /sys/class/power_supply/BAT0/capacity)
2024-10-17 16:03:04 +00:00
if [ $charge -lt $(($crit + 1)) ]; then
notify-send -c power -t 100000 battery [${charge}%]
elif [ $charge -lt $(($warn + 1)) ]; then
if [ $dismissed -eq 0 ]; then
dismissed=1
notify-send -c power -t 1000000 battery [${charge}%]
fi
fi
2024-10-17 16:03:04 +00:00
if [ $charge -gt $warn ]; then
dismissed=0
fi
2024-09-26 04:15:43 +00:00
sleep 60
done