script color for low battery

This commit is contained in:
Sakooooo 2023-08-04 18:01:45 +03:00
parent 9b7b36fe62
commit 9a2e0c9499
Signed by: sako
GPG key ID: 3FD715D87D7725E0

View file

@ -15,12 +15,21 @@ cpu() {
printf "^c$white^ ^b$grey^ $cpu_val" printf "^c$white^ ^b$grey^ $cpu_val"
} }
lowbattery() {
get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)"
if (( get_capacity <= 20)); then
printf "^c$red^ Low! $get_capacity"
else
printf "^c$blue^  $get_capacity"
fi
}
battery() { battery() {
get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)" get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)"
get_status="$(cat /sys/class/power_supply/BAT1/status)" get_status="$(cat /sys/class/power_supply/BAT1/status)"
case "$get_status" in case "$get_status" in
Charging) printf "^c$blue^ Charging $get_capacity" ;; Charging) printf "^c$blue^ Charging $get_capacity" ;;
Discharging) printf "^c$blue^  $get_capacity" ;; Discharging) $(lowbattery) ;;
esac esac
#printf "^c$blue^  $get_capacity" #printf "^c$blue^  $get_capacity"
} }