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)