update batperc and added batpercd

This commit is contained in:
wt committed 2024-07-14 19:21:51 +07:00
1 parent 41cc6db737
commit 898d3b2c59
2 files changed
+42 -14

No files matched your search

+27 -14
View File
@@ -12,21 +12,34 @@ if [[ "$batteries" == "" ]]; then
exit 1;
fi
for i in $batteries; do
batfull=$(cat /sys/class/power_supply/$i/energy_full)
batnow=$(cat /sys/class/power_supply/$i/energy_now)
batperc=$((($batnow/($batfull/100))))
case "$1" in
"-c")
for i in $batteries; do
batfull=$(cat /sys/class/power_supply/$i/energy_full)
batnow=$(cat /sys/class/power_supply/$i/energy_now)
batperc=$((($batnow/($batfull/100))))
if [[ "$batperc" -le "20" ]]; then
printf "$Yellow**$Color_off $i: $Red$batperc$Color_off\n"
exit 0
fi
if [[ "$batperc" -le "20" ]]; then
printf "$Yellow**$Color_off $i: $Red$batperc$Color_off\n"
exit 0
fi
if [[ "$batperc" -le "70" ]]; then
printf "$Yellow**$Color_off $i: $Yellow$batperc$Color_off\n"
exit 0
fi
if [[ "$batperc" -le "70" ]]; then
printf "$Yellow**$Color_off $i: $Yellow$batperc$Color_off\n"
exit 0
fi
printf "$Yellow**$Color_off $i: $Green$batperc$Color_off\n"
done
printf "$Yellow**$Color_off $i: $Green$batperc$Color_off\n"
done
;;
"-j")
for i in $batteries; do
batfull=$(cat /sys/class/power_supply/$i/energy_full)
batnow=$(cat /sys/class/power_supply/$i/energy_now)
batperc=$((($batnow/($batfull/100))))
printf "$batperc \n"
done
;;
esac
Executable
+15
View File
@@ -0,0 +1,15 @@
#!/bin/sh
batperc=$(~/dotfiles/bin/batperc -j)
echo $batperc
while true; do
for i in $batperc; do
if [[ "$i" -le "20" ]]; then
notify-send "battery low: $i%" -u critical
sleep 60
fi
done
done