Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Location of acpi files.
- path="/proc/acpi/battery/BAT0"
- full=`cat $path/info|grep 'last full capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`
- current=`cat $path/state|grep 'remaining capacity'|awk -F: '{print $2}'|awk -Fm '{print $1}'`
- state=$(( current * 100 / $full))
- charstate=`cat $path/state|sed '1,2d'|sed '2,4d'|sed 's/charging//'|sed 's/state://'|tr -d " "`
- if [ "$charstate" = "discharging" ]
- then
- if [[ "$state" -lt "90" && "$state" -gt "75" ]]
- then
- echo "75%"
- fi
- if [[ "$state" -lt "75" && "$state" -gt "60" ]]
- then
- echo "60%"
- fi
- if [[ "$state" -lt "60" && "$state" -gt "45" ]]
- then
- echo "45%"
- fi
- if [[ "$state" -lt "45" && "$state" -gt "30" ]]
- then
- echo "30%"
- fi
- if [[ "$state" -lt "30" && "$state" -gt "15" ]]
- then
- echo "15%"
- fi
- if [[ "$state" -lt "15" && "$state" -gt "10" ]]
- then
- echo "10%"
- fi
- if [ "$state" -lt "10" ]
- then
- echo "PLUG AND PRAY"
- fi
- fi
- if [ "$charstate" = "charged" ]
- then
- echo "CHARGED YEA."
- fi
- if [ "$charstate" = "charging" ]
- then
- echo "Charging"
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement