Created
August 12, 2019 17:01
-
-
Save rrooij/1a71defa9a3cc6f42dc6366d35b2b1da to your computer and use it in GitHub Desktop.
Cron for checking battery life
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/sh | |
# Change BAT according to the battery you want to check | |
BATCAP=$(cat /sys/class/power_supply/BAT1/capacity) | |
WARNING_THRESHOLD=$1 | |
export DISPLAY=:0 | |
if [ -z "$WARNING_THRESHOLD" ]; then | |
WARNING_THRESHOLD=20 | |
fi | |
if [ "$BATCAP" -lt "$WARNING_THRESHOLD" ]; then | |
notify-send "Low battery" "Battery at $BATCAP" -u critical | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment