2018-12-02 23:43:08 +00:00
|
|
|
#!/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
|
2018-12-03 08:31:44 +00:00
|
|
|
bat_cap+=("$(cat "${bat}/capacity")%")
|
2018-12-02 23:43:08 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ ${ac_conn} -eq 0 ]; then
|
2018-12-03 08:31:44 +00:00
|
|
|
printf '\uf58d %s' "${bat_cap[*]}"
|
2018-12-02 23:43:08 +00:00
|
|
|
else
|
2018-12-03 08:31:44 +00:00
|
|
|
printf '\uf740 %s' "${bat_cap[*]}"
|
2018-12-02 23:43:08 +00:00
|
|
|
fi
|