Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- _BAT_STATUS=$(acpitool | grep Battery | gawk '{print $4}' | sed -e 's/,//g')
- #_BAT_TIME=$(acpitool | grep Battery | gawk '{print $6}' | sed -e 's/://g' | sed -e 's/^0*//')
- _BAT_PERCENT=$(acpitool | grep Battery | gawk '{print $5}' | sed -e 's/,//g' -e 's/%//g' -e 's/\.//g')
- # test area
- #echo "_BAT_STATUS: $_BAT_STATUS \n _BAT_TIME: $_BAT_TIME"
- while [ "$_BAT_STATUS" == "discharging" ]
- do
- if [[ "$_BAT_PERCENT" -ge 1000 ]];
- then
- exit
- elif [[ "$_BAT_PERCENT" -ge 700 && "$_BAT_PERCENT" -lt 999 ]];
- then
- DISPLAY=:0 sudo -u alie notify-send "Information" "Low power detected" -i /usr/share/icons/hicolor/32x32/actions/Alert-icon.png
- sleep 40
- if [ `acpitool | grep Battery | gawk '{print $4}' | sed -e 's/,//g'` == "discharging" ];
- then
- shutdown -h now
- else
- exit
- fi
- elif [[ "$_BAT_PERCENT" -lt 700 ]];
- then
- shutdown -h now
- else
- exit
- fi
- ######Energy monitor block
- # if [[ "$_BAT_TIME" -le 1000000 && "$_BAT_TIME" -ge 160 ]];
- # then
- # exit
- # elif [[ "$_BAT_TIME" -le 160 && "$_BAT_TIME" -ge 132 ]];
- # then
- # DISPLAY=:0 sudo -u alie notify-send "Information" "Low power detected" -i /usr/share/icons/hicolor/32x32/actions/Alert-icon.png
- # sleep 40
- # if [ `acpitool | grep Battery | gawk '{print $4}' | sed -e 's/,//g'` == "discharging" ];
- # then
- # shutdown -h now
- # else
- # exit
- # fi
- # elif [ "$_BAT_TIME" -lt 132 ];
- # then
- # shutdown -h now
- # else
- # exit
- # fi
- ########
- exit
- done
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement