Created
April 7, 2013 22:39
-
-
Save atn34/5332873 to your computer and use it in GitHub Desktop.
Notifies you if your battery is below a certain threshold and isn't charging. I'm using it for xmonad
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/sh | |
# | |
# Script for notifying when battery is low | |
# Set it up as a cronjob with | |
# | |
# $ crontab -e | |
# | |
# put the following in your crontab file to check every minute | |
# | |
# * * * * * env DISPLAY=:0.0 <absolute path to script> | |
# | |
# get percentage of battery left | |
PERCENT=`acpi | cut -d , -f2` | |
PERCENT=${PERCENT%\%} | |
# only notify if percent is under WARNINGLEVEL | |
WARNINGLEVEL=10 | |
# don't notify if battery is charging | |
if [ $PERCENT -lt $WARNINGLEVEL ] && acpi -a | grep 'off-line' | |
then | |
notify-send --urgency=normal "Battery low!" "$PERCENT% left" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment