rice/dots/.config/sway/status_command
2024-05-20 12:06:16 +02:00

24 lines
557 B
Bash
Executable file

#!/bin/sh
while :; do
energy_full=0
energy_now=0
charging=
for bat in /sys/class/power_supply/*/capacity; do
bat="${bat%/*}"
read -r full <"$bat/energy_full"
read -r now <"$bat/energy_now"
energy_full=$((energy_full + full))
energy_now=$((energy_now + now))
done
if cat /sys/class/power_supply/*/status | grep -q Charging; then
charging=+
fi
percentage=$((energy_now * 100 / energy_full))
printf '%s %s ' "$charging$percentage%" "$(date +'%H:%M:%S')"
sleep 1
done