#!/bin/bash

shopt -s extglob

declare -a batteries

for battery_path in /sys/class/power_supply/!(AC*); do
	status="$(cat "${battery_path}/status")" 

	case "${status}" in
		"Full") status_string="⚡" ;;
		"Discharging") status_string="🔋" ;;
		"Charging") status_string="🔌" ;;
		"Not charging") status_string="🛑" ;;
		"Unknown") status_string="♻️" ;;
		*) status_string="??" ;;
	esac

	capacity="$(cat "${battery_path}/capacity")"
	[ "$status" = "Discharging" ] && [ "$capacity" -le 25 ] && status_string="❗"

	batteries+=("${status_string} ${capacity}%")
done

echo "${batteries[@]}"
