summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/.local/bin/bat_check.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/.local/bin/bat_check.sh b/bin/.local/bin/bat_check.sh
index b54ce7b..abfb06f 100755
--- a/bin/.local/bin/bat_check.sh
+++ b/bin/.local/bin/bat_check.sh
@@ -2,12 +2,13 @@
2while true 2while true
3do 3do
4 battery_level=$(cat /sys/class/power_supply/BAT0/capacity) 4 battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
5 if [ $battery_level -ge 95 ]; then 5 state=$(cat /sys/class/power_supply/BAT0/status)
6 if [ $battery_level -ge 95 ] && [ $state == "Discharging" ]; then
6 notify-send 'Pull the plug!' $battery_level% 7 notify-send 'Pull the plug!' $battery_level%
7 elif [ $battery_level -le 30 -a $battery_level -ge 20 ]; then 8 elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then
8 notify-send 'Plug me!' $battery_level% 9 notify-send 'Plug me!' $battery_level%
9 elif [ $battery_level -le 20 ]; then 10 elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then
10 notify-send -u critical 'Plug me NOW!' $battery_level% 11 notify-send -u critical 'Plug me NOW!' $battery_level%
11 fi 12 fi
12 sleep 300 # 300 seconds or 5 minutes 13 sleep 2 # 300 seconds or 5 minutes
13done 14done