From 3a9f673f22cc8d724eed55830a57343ae10b800c Mon Sep 17 00:00:00 2001 From: "Scott C. MacCallum" Date: Tue, 26 Nov 2024 15:08:47 -0500 Subject: [PATCH] Fixed if statement variable --- battery-monitor.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/battery-monitor.sh b/battery-monitor.sh index e3d345f..d40faef 100755 --- a/battery-monitor.sh +++ b/battery-monitor.sh @@ -35,16 +35,17 @@ group="scm" battery="BAT0" -# If the battery is fully charged, exit the program. - -if (( minutes == 0 )); then - exit 0 -fi - # Calculate the number of minutes that the battery has left. charge=$(cat /sys/class/power_supply/$battery/charge_now) discharge=$(cat /sys/class/power_supply/$battery/current_now) + +# If the computer is plugged in, exit the program. + +if (( discharge == 0 )); then + exit 0 +fi + hours=$(echo "scale=2; $charge / $discharge" | bc -l) minutes=$(echo "scale=2; $hours * 60" | bc -l)