battery (261B)
1 #!/bin/sh 2 # 3 # 4 5 status () { 6 cat /sys/class/power_supply/BAT?/status 7 } 8 9 level () { 10 BAT=`cat /sys/class/power_supply/BAT?/capacity` 11 echo "${BAT}%" 12 } 13 14 usage () { 15 echo "usage: $(basename $0) [-hs]" 16 } 17 18 19 case $1 in 20 -s) status ;; 21 -h) usage ;; 22 *) level ;; 23 esac