update batperc and added batpercd
This commit is contained in:
1 parent
41cc6db737
commit
898d3b2c59
2 files changed
+42
-14
No files matched your search
+27
-14
@@ -12,21 +12,34 @@ if [[ "$batteries" == "" ]]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in $batteries; do
|
case "$1" in
|
||||||
batfull=$(cat /sys/class/power_supply/$i/energy_full)
|
"-c")
|
||||||
batnow=$(cat /sys/class/power_supply/$i/energy_now)
|
for i in $batteries; do
|
||||||
batperc=$((($batnow/($batfull/100))))
|
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
|
if [[ "$batperc" -le "20" ]]; then
|
||||||
printf "$Yellow**$Color_off $i: $Red$batperc$Color_off\n"
|
printf "$Yellow**$Color_off $i: $Red$batperc$Color_off\n"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$batperc" -le "70" ]]; then
|
if [[ "$batperc" -le "70" ]]; then
|
||||||
printf "$Yellow**$Color_off $i: $Yellow$batperc$Color_off\n"
|
printf "$Yellow**$Color_off $i: $Yellow$batperc$Color_off\n"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "$Yellow**$Color_off $i: $Green$batperc$Color_off\n"
|
printf "$Yellow**$Color_off $i: $Green$batperc$Color_off\n"
|
||||||
done
|
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
@@ -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
|
||||||
|
|
||||||
Reference in new issue
Block a user