Created
December 1, 2016 16:39
-
-
Save shaposhnikoff/e2025a7b4e234e74fb2bf8915b2e61d0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/bin/bash | |
| if [ -e /sys/class/power_supply/BAT0 ]; then | |
| zenity --warning --text "STARTED MONITORING BATERY" | |
| while true;do | |
| CAPACITY=$( cat /sys/class/power_supply/BAT0/uevent | grep -i capacity | cut -d'=' -f2|head -1 ) | |
| case $CAPACITY in | |
| [0-9]|11) | |
| STATUS=$( cat /sys/class/power_supply/BAT0/uevent | grep -i status | cut -d'=' -f2 | head -1) | |
| if [ $(echo $STATUS) == "Discharging" ]; then | |
| # notify-send --urgency=critical --icon=dialog-warning "LOW BATTERY! SUSPENDING IN 30 sec" | |
| zenity --warning --text "LOW BATTERY! SUSPENDING IN 30 sec" | |
| sleep 30 | |
| gnome-screensaver-command -l && sudo pm-suspend | |
| break | |
| fi | |
| ;; | |
| *) | |
| sleep 1 | |
| continue | |
| ;; | |
| esac | |
| done | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment