Last active
October 8, 2015 08:43
-
-
Save theSage21/f05ea7ee593e1c6e906d to your computer and use it in GitHub Desktop.
ratpoison low battery alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ratbatalert () | |
{ | |
# low battery alert for ratpoison | |
while true; | |
do | |
batt=$(upower -e|grep BAT0) | |
string_percent=$(upower -i $batt|grep 'percent') | |
percent=$(sed "s,percentage: ,," <<< $string_percent) | |
number=${percent::-1} | |
state=$(upower -i $batt|grep 'state') | |
sta=$(sed "s,state: ,," <<< $state) | |
state=`tr '[:lower:]' '[:upper:]' <<< ${sta::3}` | |
if (($number < $1 )); then | |
ratpoison -c "echo $state:BatLow:$number "; | |
fi | |
sleep 1 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment