scripts/i3blocks/battery_status.sh

13 lines
279 B
Bash
Raw Normal View History

2024-11-15 13:13:49 +01:00
#!/bin/bash
acpi -b | awk -F', ' '
/Battery/ {
split($2, percent, "%")
split($3, time, " ")
printf " %d%%", percent[1]
2024-11-15 13:13:49 +01:00
if (time[1] != "") printf ", %s", time[1]
if ($1 ~ /Charging/) printf ", Charging"
printf "\n"
}'