nixos-config/modules/home/sketchybar/plugins/battery.sh

16 lines
369 B
Bash
Raw Normal View History

2026-02-21 23:19:14 +01:00
#!/bin/bash
PERCENTAGE="$(pmset -g batt | grep -Eo "...%" | awk '{print $1}')"
CHARGING="$(pmset -g batt | grep 'AC Power')"
# The item invoking this script (name $NAME) will get its icon and label
# updated with the current battery status
if [[ "$CHARGING" != "" ]]; then
STATE="CHAR:"
else
STATE="BATT:"
fi
sketchybar --set "$NAME" label="$STATE $PERCENTAGE"