bin

git clone git://git.codymlewis.com/bin.git
Log | Files | Refs

battery (404B)


      1 #!/bin/sh
      2 
      3 cap=$(cat /sys/class/power_supply/BAT0/capacity)
      4 if grep 'Discharging' /sys/class/power_supply/BAT0/status > /dev/null; then
      5 	if [ "$cap" -lt 20 ]; then
      6 		baticon=""
      7 	elif [ "$cap" -lt  40 ]; then
      8 		baticon=""
      9 	elif [ "$cap" -lt 60 ]; then
     10 		baticon=""
     11 	elif [ "$cap" -lt 80 ]; then
     12 		baticon=""
     13 	else
     14 		baticon=""
     15 	fi
     16 else
     17 	baticon=""
     18 fi
     19 printf "%s %s%% " "$baticon" "$cap"