#!/bin/sh
# prefix_cmd for the battery module -- picks a Nerd Font glyph based on
# charge level and charging status.
# $1 is the battery module's own output (e.g. "88%"); charging status isn't
# in that string, so we re-check /sys ourselves.
pct=$(printf '%s' "$1" | tr -dc '0-9')
pct=${pct:-0}
status=$(cat /sys/class/power_supply/BAT*/status 2>/dev/null | head -n1)

if [ "$status" = "Charging" ]; then
    printf '%s ' ''
    exit 0
fi

if   [ "$pct" -ge 90 ]; then printf '%s ' ''
elif [ "$pct" -ge 50 ]; then printf '%s ' ''
elif [ "$pct" -ge 20 ]; then printf '%s ' ''
elif [ "$pct" -ge 10 ]; then printf '%s ' ''
else printf '%s ' ''
fi
