#!/bin/bash
set -euo pipefail

ac_conn=0
for ac in $(find /sys/class/power_supply -type l -name 'A*'); do
	[ $(cat "${ac}/online") -eq 1 ] && ac_conn=1
done

bat_cap=()
for bat in $(find /sys/class/power_supply -type l -name 'B*'); do
	bat_cap+=("$(cat "${bat}/capacity")%")
done

if [ ${ac_conn} -eq 0 ]; then
	printf '\uf58d %s' "${bat_cap[*]}"
else
	printf '\uf740 %s' "${bat_cap[*]}"
fi