12345678910111213141516171819202122232425262728293031323334 |
- #!/bin/sh
- BATTERY="/sys/class/power_supply/BAT0"
- [ -e ${BATTERY} ] || exit 33
- STATUS=$(cat "${BATTERY}/status")
- CAPACITY=$(cat "${BATTERY}/capacity")
- case ${STATUS} in
- Discharging)
- if [ "${CAPACITY}" -lt 1 ] ; then
- exit 33
- elif [ "${CAPACITY}" -lt 6 ] ; then
- ICON=""
- elif [ "${CAPACITY}" -lt 26 ] ; then
- ICON=""
- elif [ "${CAPACITY}" -lt 76 ] ; then
- ICON=""
- elif [ "${CAPACITY}" -lt 96 ] ; then
- ICON=""
- else
- ICON=""
- fi
- ;;
- Full|Charging|Unknown)
- ICON=""
- ;;
- esac
- echo "${ICON} ${CAPACITY}%"
- exit 0
|