Advertisement
clairec

battery.sh

Dec 28th, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.36 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. PTOT=$(</sys/class/power_supply/BAT1/charge_full)
  4. PNOW=$(</sys/class/power_supply/BAT1/charge_now)
  5. PERCR=$(echo "$PNOW / $PTOT * 100" | bc -l)
  6. PERCS=${PERCR:0:2}
  7. PERC=${PERCS#0}
  8. LOWPOWER=20
  9.  
  10. if [ $PERC -lt $LOWPOWER ]
  11.   then
  12.     echo -en "\033[1;31m"
  13. fi
  14.  
  15. echo -n $PERC%
  16.  
  17. if [ $PERC -lt $LOWPOWER ]
  18.   then
  19.     echo -en "\033[0m"
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement