I38/scripts/battery_status.sh

18 lines
430 B
Bash
Raw Normal View History

2022-11-30 17:47:37 -05:00
#!/usr/bin/env bash
#check for acpi
if command -v acpi &> /dev/null; then
spd-say -P important -Cw "$bat"
else
find /sys/class/power_supply -type l -exec bash -c '
2022-11-30 17:47:37 -05:00
for i ; do
if [[ -e "$i/capacity" ]]; then
bat="${i##*/}"
bat="${bat//BAT/Battery }"
bat="${bat}: $(cat "${i}/capacity") percent"
spd-say -P important -Cw "$bat"
fi
done
' _ {} \;
fi