Erroneous class for critical battery

This commit is contained in:
John Mertz 2023-09-15 22:56:49 -06:00
parent 1247df0cce
commit 57ebe092ba
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
1 changed files with 46 additions and 46 deletions

View File

@ -6,53 +6,53 @@ LEVEL=$(echo $ACPI | cut -d',' -f2 | sed 's/\s//g' | sed 's/%$//')
TIME=$(echo $ACPI | cut -d',' -f3 | sed 's/\s//') TIME=$(echo $ACPI | cut -d',' -f3 | sed 's/\s//')
CLASS="unknown" CLASS="unknown"
if [[ -z $1 ]]; then if [[ -z $1 ]]; then
echo "$STATUS $LEVEL ($TIME)" echo "$STATUS $LEVEL ($TIME)"
elif [[ $1 == bar ]]; then elif [[ $1 == bar ]]; then
case "$STATUS" in case "$STATUS" in
"Discharging") "Discharging")
CLASS="discharging" CLASS="discharging"
case "$LEVEL" in case "$LEVEL" in
[8-9][0-9]) [8-9][0-9])
STATUS=" " STATUS=" "
;; ;;
[6-7][0-9]) [6-7][0-9])
STATUS=" " STATUS=" "
;; ;;
[4-5][0-9]) [4-5][0-9])
STATUS=" " STATUS=" "
;; ;;
[2-3][0-9]) [2-3][0-9])
STATUS=" " STATUS=" "
;; ;;
1[0-9]) 1[0-9])
CLASS="low" CLASS="low"
STATUS=" " STATUS=" "
;; ;;
[1-9]) [1-9])
CLASS="charging" CLASS="critical"
STATUS=" " STATUS=" "
;; ;;
*) *)
STATUS="? " STATUS="? "
;; ;;
esac esac
;; ;;
"Not charging") "Full")
CLASS="ac" CLASS="ac"
STATUS=" " STATUS=" "
;; ;;
"Charging") "Charging")
CLASS="charging" CLASS="charging"
STATUS="🗲 " STATUS="🗲"
;; ;;
*) *)
STATUS="✘ " STATUS="✘"
;; ;;
esac esac
printf '{"text":"%b%%","icon":"%b ","percentage":"%b","tooltip":"%b","class":"%b"}' "${STATUS}${LEVEL}" $STATUS $LEVEL "$TIME" $CLASS printf '{"text":"%b%%","icon":"%b ","percentage":"%b","tooltip":"%b","class":"%b"}' "${STATUS}${LEVEL}" $STATUS $LEVEL "$TIME" $CLASS
exit exit
elif [[ $1 == 'notify' ]]; then elif [[ $1 == 'notify' ]]; then
notify-send Battery "$(echo $ACPI | cut -d':' -f2- | sed 's/\s//')" notify-send Battery "$(echo $ACPI | cut -d':' -f2- | sed 's/\s//')"
else else
echo "invalid option $1" echo "invalid option $1"
fi fi