From d86513837b98961e5fbcffa4c743063d65a26509 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 16 Jun 2025 11:52:31 +0100 Subject: Fix battcheck when CURRENT_NOW is 0/empty --- battcheck | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'battcheck') diff --git a/battcheck b/battcheck index 4a6ce1f..c047549 100755 --- a/battcheck +++ b/battcheck @@ -1,12 +1,14 @@ #!/bin/awk -f -# Copyright (C) 2020 Tomasz Kramkowski +# Copyright (C) 2020, 2025 Tomasz Kramkowski # SDPX-License-Identifier: MIT BEGIN { FS = "=" } { a[substr($1, 14)] = $2 } END { if (a["STATUS"] != "Discharging") exit 0 - time_left = a["ENERGY_NOW"] / a["POWER_NOW"] * 3600 - if (min_time && time_left < min_time) exit 1 + if (+a["CURRENT_NOW"] != 0) { + time_left = a["CHARGE_NOW"] / a["CURRENT_NOW"] * 3600 + if (min_time && time_left < min_time) exit 1 + } if (min_pct && a["CAPACITY"] < min_pct) exit 1 exit 0 } -- cgit v1.2.3-70-g09d2