Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # environment variables
- #export DISPLAY =:0.0
- # variables
- _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*//')
- # test area
- #echo "_BAT_STATUS: $_BAT_STATUS \n _BAT_TIME: $_BAT_TIME"
- while [ "$_BAT_STATUS" == "discharging" ]
- do
- if [[ "$_BAT_TIME" -le 1000000 && "$_BAT_TIME" -ge 1000 ]];
- then
- exit
- elif [[ "$_BAT_TIME" -le 1000 && "$_BAT_TIME" -ge 500 ]];
- then
- 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 500 ];
- then
- shutdown -h now
- else
- exit
- fi
- exit
- done
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement