2021-03-02 03:06:38 +00:00
|
|
|
#!/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>
|
2022-01-15 05:33:32 +00:00
|
|
|
# MIT License
|
2021-03-02 03:06:38 +00:00
|
|
|
|
|
|
|
flag1=0
|
|
|
|
flag2=0
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
charge=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
|
|
if [ $charge -lt 11 ]; then
|
|
|
|
if [ $flag1 -eq 0 ]; then
|
|
|
|
flag1=1
|
2021-03-04 05:26:34 +00:00
|
|
|
notify-send -t 10000 battery [${charge}%]
|
2021-03-02 03:06:38 +00:00
|
|
|
fi
|
|
|
|
elif [ $charge -lt 21 ]; then
|
|
|
|
if [ $flag2 -eq 0 ]; then
|
|
|
|
flag2=1
|
2021-03-04 05:26:34 +00:00
|
|
|
notify-send -t 10000 battery [${charge}%]
|
2021-03-02 03:06:38 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $charge -gt 20 ]; then
|
|
|
|
flag2=0
|
|
|
|
fi
|
|
|
|
if [ $charge -gt 10 ]; then
|
|
|
|
flag1=0
|
|
|
|
fi
|
|
|
|
|
2024-09-26 04:15:43 +00:00
|
|
|
sleep 60
|
2021-03-02 03:06:38 +00:00
|
|
|
done
|
|
|
|
|