added slstatus
This commit is contained in:
1 parent
2eee2f75c0
commit
89e5167279
39 files changed
+3002
-1
No files matched your search
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
Green='\033[0;32m'
|
||||
Color_off='\033[0m'
|
||||
Red='\033[0;31m'
|
||||
Yellow='\033[1;33m'
|
||||
|
||||
batteries=$(ls /sys/class/power_supply/ | grep BAT)
|
||||
|
||||
case "$1" in
|
||||
"-c")
|
||||
if [[ "$batteries" == "" ]]; then
|
||||
printf "$Yellow**$Red error:$Color_off no battery found\n"
|
||||
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))))
|
||||
|
||||
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
|
||||
|
||||
printf "$Yellow**$Color_off $i: $Green$batperc$Color_off\n"
|
||||
done
|
||||
;;
|
||||
"-j")
|
||||
if [[ "$batteries" == "" ]]; then
|
||||
echo no
|
||||
exit 1;
|
||||
fi
|
||||
for i in $batteries; do
|
||||
batfull=$(cat /sys/class/power_supply/$i/charge_full)
|
||||
batnow=$(cat /sys/class/power_supply/$i/charge_now)
|
||||
batperc=$((($batnow/($batfull/100))))
|
||||
|
||||
printf "$batperc \n"
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in new issue
Block a user