This is a rewrite of Battery levels by Wayne Folta to handle international characters. Waynes original text below.
The Apple Batteries widget can only show 4 things (in Small and Medium size) and you exceed that if you use an Apple Magic Keyboard (1), Apple Magic Trackpad (1), Apple Airpods (2) and your MacBook Pro itself (1). So I made this widget that is plain text, but does the job. I run it from cron every 15 minutes.
Place an image in ~/Pictures/battery-bg.jpg for a background image.
Set the target widget target in TW_TARGET
Script (widget-batteries-utf8.sh)
#!/bin/bashTW=/Applications/TerminalWidget.app/Contents/MacOS/TerminalWidget
BG_IMAGE="$HOME/Pictures/battery-bg.jpg"# any local photoTW_TARGET="batteries"raw=$(/usr/bin/pmset -g accps \|LC_ALL=C /usr/bin/tr '\325'"'"\| /usr/bin/iconv -f MACROMAN -t UTF-8)case"$raw"in
*"'AC Power'"*)title=":electric_plug: On AC Power";;
*)title=":battery: On Battery Power";;esacprintf'%s\n'"$raw"\| /usr/bin/awk -F '\t'' /^Now drawing from/ { next } NF >= 2 { name = $1 sub(/^[[:space:]]*-/, "", name) sub(/[[:space:]]*\(id=[^)]*\)[[:space:]]*$/, "", name) if (name ~ /^InternalBattery/) name = "This Mac" pct = $2 sub(/%.*/, "", pct) pct += 0 filled = int((pct + 5) / 10) meter = "" for (i = 1; i <= 10; i++) meter = meter (i <= filled ? "▰" : "▱") rows = rows name "\t" meter "\t" pct "%\n" } END { printf "Device\tCharge\tLevel\n%s", rows } '\|"$TW" --target $TW_TARGET\
--table - \
--grid zebra-row \
--table-layout fill \
--table-align left,left,right \
--title "$title"\
--background-image "$BG_IMAGE"\
--filter alpha:30 \
--bg "#0f172a"\
--fg "#e2e8f0"