#!/usr/bin/env bash

color8="#88C0D0"

icon(){
    printf "%s\\n" "%{F${color8}}${1}%{F}"
}   

icon2() {
    printf "%s\\n" "%{F${color11:-#F0F0F0}}${1}%{F}"
}

status=$(acpiconf -i 0 | grep State | cut -c 10-)
capacity=$(acpiconf -i 0 | grep % | cut -f2 | cut -c -4 | sed s/%//)

if [ "$status" == "charging" ]; then
    printf "%s\\n" "$(icon "") ${capacity}%"
elif [ "$status" == "high" ]; then
    printf "%s\\n" "$(icon "") ${capacity}%"
elif (("$capacity" <= "20")); then
    printf "%s\\n" "$(icon2 "") ${capacity}%"
elif (("$capacity" <= "60")); then
    printf "%s\\n" "$(icon "") ${capacity}%"
elif (("$capacity" <= "100")); then
    printf "%s\\n" "$(icon "") ${capacity}%"
fi
