battery.sh 243 B

12345678
  1. #!/usr/bin/env bash
  2. # Outputs battery charge percentage and status
  3. # e.g. Battery 0: 85% (Discharging)
  4. for bi in /sys/class/power_supply/BAT*; do
  5. [ -f "${bi}" ] && echo "Battery ${bi:27:1}: $(cat ${bi}/capacity)% ($(cat ${bi}/status))"
  6. done