Last active
December 17, 2015 17:59
-
-
Save otsuarez/5649564 to your computer and use it in GitHub Desktop.
battery status reporting under i3
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
#!/bin/bash | |
# crontab -e | |
# */10 * * * * DISPLAY=:0.0 ${HOME}/bin/battery.sh | |
NOW=`echo $((100*$(sed -n "s/remaining capacity: *\(.*\) m[AW]h/\1/p" /proc/acpi/battery/BAT0/state)/$(sed -n "s/last full capacity: *\(.*\) m[AW]h/\1/p" /proc/acpi/battery/BAT0/info)))` | |
THRESHOLD="30" | |
if [ $NOW -lt $THRESHOLD ]; | |
then | |
/usr/bin/i3-nagbar -m "Battery status critical (below "$THRESHOLD"%)" -b 'pm-suspend' 'sudo pm-suspend' | |
#notify-send "Battery status critical (below "$THRESHOLD"%)" | |
fi | |
#notify-send "Battery status: $NOW%" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment