34 lines
675 B
Bash
Executable file
34 lines
675 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# Just a background script to tell you when your battery's low if you don't
|
|
# have a panel.
|
|
# Lisenced under the MIT license -- do what you want
|
|
# Copyleft 2021 Derek Stevens <drkste@zoho.com>
|
|
|
|
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
|
|
notify-send -t 10000 BATTERY ${charge}%
|
|
fi
|
|
elif [ $charge -lt 21 ]; then
|
|
if [ $flag2 -eq 0 ]; then
|
|
flag2=1
|
|
notify-send -t 10000 BATTERY ${charge}%
|
|
fi
|
|
fi
|
|
|
|
if [ $charge -gt 20 ]; then
|
|
flag2=0
|
|
fi
|
|
if [ $charge -gt 10 ]; then
|
|
flag1=0
|
|
fi
|
|
|
|
sleep 30
|
|
done
|
|
|