battery 565 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. BATTERY="/sys/class/power_supply/BAT0"
  3. [ -e ${BATTERY} ] || exit 33
  4. STATUS=$(cat "${BATTERY}/status")
  5. CAPACITY=$(cat "${BATTERY}/capacity")
  6. case ${STATUS} in
  7. Discharging)
  8. if [ "${CAPACITY}" -lt 1 ] ; then
  9. exit 33
  10. elif [ "${CAPACITY}" -lt 6 ] ; then
  11. ICON="󰁺"
  12. elif [ "${CAPACITY}" -lt 26 ] ; then
  13. ICON="󰁼"
  14. elif [ "${CAPACITY}" -lt 76 ] ; then
  15. ICON="󰁾"
  16. elif [ "${CAPACITY}" -lt 96 ] ; then
  17. ICON="󰂀"
  18. else
  19. ICON="󰂂"
  20. fi
  21. ;;
  22. Full|Charging|Unknown)
  23. ICON="󰂄"
  24. ;;
  25. esac
  26. echo "${ICON} ${CAPACITY}%"
  27. exit 0