2023-09-06 21:04:41 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-07-29 16:45:58 +02:00
|
|
|
|
2023-09-06 21:04:41 +02:00
|
|
|
source "${UTIL_DIR}/colors.sh"
|
2023-07-29 16:45:58 +02:00
|
|
|
|
2023-09-06 21:04:41 +02:00
|
|
|
BATT_PERCENT=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
|
|
|
|
CHARGING=$(pmset -g batt | grep 'AC Power')
|
2023-07-29 16:45:58 +02:00
|
|
|
|
2023-09-06 21:04:41 +02:00
|
|
|
sketchybar --set "${NAME}" icon.color=0xff989898
|
2023-07-29 16:45:58 +02:00
|
|
|
|
|
|
|
if [ ${CHARGING} != "" ]; then
|
2023-09-06 21:04:41 +02:00
|
|
|
case ${BATT_PERCENT} in
|
|
|
|
100)
|
|
|
|
ICON=""
|
|
|
|
COLOR="${GREEN}"
|
|
|
|
;;
|
|
|
|
9[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${GREEN}"
|
|
|
|
;;
|
|
|
|
8[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${GREEN}"
|
|
|
|
;;
|
|
|
|
7[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${GREEN}"
|
|
|
|
;;
|
|
|
|
6[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${YELLOW}"
|
|
|
|
;;
|
|
|
|
5[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${YELLOW}"
|
|
|
|
;;
|
|
|
|
4[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${ORANGE}"
|
|
|
|
;;
|
|
|
|
3[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${ORANGE}"
|
|
|
|
;;
|
|
|
|
2[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${RED}"
|
|
|
|
;;
|
|
|
|
1[0-9])
|
|
|
|
ICON=""
|
|
|
|
COLOR="${RED}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ICON=""
|
|
|
|
COLOR="${RED}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
sketchybar --set "${NAME}" icon="${ICON}" icon.color="${COLOR}"
|
|
|
|
sketchybar --set "${NAME}" label="${BATT_PERCENT}%"
|
|
|
|
else
|
|
|
|
case ${BATT_PERCENT} in
|
|
|
|
100) ICON="" COLOR="$GREEN" ;;
|
|
|
|
9[0-9]) ICON="" COLOR="$GREEN" ;;
|
|
|
|
8[0-9]) ICON="" COLOR="$GREEN" ;;
|
|
|
|
7[0-9]) ICON="" COLOR="$GREEN" ;;
|
|
|
|
6[0-9]) ICON="" COLOR="$YELLOW" ;;
|
|
|
|
5[0-9]) ICON="" COLOR="$YELLOW" ;;
|
|
|
|
4[0-9]) ICON="" COLOR="$ORANGE" ;;
|
|
|
|
3[0-9]) ICON="" COLOR="$ORANGE" ;;
|
|
|
|
2[0-9]) ICON="" COLOR="$RED" ;;
|
|
|
|
1[0-9]) ICON="" COLOR="$RED" ;;
|
|
|
|
*) ICON="" COLOR="$RED" ;;
|
|
|
|
esac
|
2023-07-29 16:45:58 +02:00
|
|
|
|
2023-09-06 21:04:41 +02:00
|
|
|
sketchybar --set "${NAME}" icon="${ICON}" icon.color="${COLOR}"
|
|
|
|
sketchybar --set "${NAME}" label="${BATT_PERCENT}%"
|
|
|
|
fi
|