Last active
November 29, 2020 20:07
-
-
Save alkhachatryan/e98fd2b285601fa1a9311bbb980b8d18 to your computer and use it in GitHub Desktop.
LINUX | Check the battery power
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 | |
#IF statment will use this var to notify user about low battery | |
LESS_THAN=70 | |
#Interval in sec | |
INTERVAL=30 | |
while true; | |
do | |
STR=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage) | |
VALUE=${STR//[A-Z a : %]/} | |
if [ $VALUE -lt $LESS_THAN ] ; then | |
notify-send "Battery is low: $VALUE%" | |
fi | |
sleep $INTERVAL; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment