From 9a334a3d5ffda8aa26302e729fe504dc6400fc1e Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Wed, 3 Jun 2020 16:26:37 +0530 Subject: changed bat_check --- bin/.local/bin/bat_check.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') 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 @@ while true do battery_level=$(cat /sys/class/power_supply/BAT0/capacity) - if [ $battery_level -ge 95 ]; then + state=$(cat /sys/class/power_supply/BAT0/status) + if [ $battery_level -ge 95 ] && [ $state == "Discharging" ]; then notify-send 'Pull the plug!' $battery_level% - elif [ $battery_level -le 30 -a $battery_level -ge 20 ]; then + elif [ $battery_level -le 30 -a $battery_level -ge 20 ] && [ $state == "Discharging" ]; then notify-send 'Plug me!' $battery_level% - elif [ $battery_level -le 20 ]; then + elif [ $battery_level -le 20 ] && [ $state == "Discharging" ]; then notify-send -u critical 'Plug me NOW!' $battery_level% fi - sleep 300 # 300 seconds or 5 minutes + sleep 2 # 300 seconds or 5 minutes done -- cgit v1.2.3