Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.18 KB | None | 0 0
  1. #!/bin/bash
  2.                                                                                
  3. # Location of acpi files.
  4. path="/proc/acpi/battery/BAT0"
  5.  
  6. full=`cat $path/info|grep 'last full capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`
  7. current=`cat $path/state|grep 'remaining capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`
  8. state=$(( current * 100 / $full))
  9. charstate=`cat $path/state|sed '1,2d'|sed '2,4d'|sed 's/charging//'|sed 's/state://'|tr -d " "`
  10.  
  11.  
  12. if [ "$charstate" = "discharging" ]
  13.     then
  14.  
  15. if [[ "$state" -lt "90" && "$state" -gt "75" ]]
  16.     then
  17. echo "75%"
  18. fi
  19.  
  20. if [[ "$state" -lt "75" && "$state" -gt "60" ]]
  21.         then
  22. echo "60%"
  23. fi
  24.  
  25. if [[ "$state" -lt "60" && "$state" -gt "45" ]]
  26.         then
  27. echo "45%"
  28. fi
  29.  
  30. if [[ "$state" -lt "45" && "$state" -gt "30" ]]
  31.         then
  32. echo "30%"
  33. fi
  34.  
  35. if [[ "$state" -lt "30" && "$state" -gt "15" ]]
  36.         then
  37. echo "15%"
  38. fi
  39.  
  40. if [[ "$state" -lt "15" && "$state" -gt "10" ]]
  41.         then
  42. echo "10%"
  43. fi
  44.  
  45. if [ "$state" -lt "10" ]
  46.         then
  47. echo "PLUG AND PRAY"
  48. fi
  49.  
  50. fi
  51.  
  52. if [ "$charstate" = "charged" ]
  53.     then
  54. echo "CHARGED YEA."
  55.  
  56. fi
  57.  
  58. if [ "$charstate" = "charging" ]
  59.     then
  60. echo "Charging"
  61.  
  62. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement