aboutsummaryrefslogtreecommitdiffstats
path: root/battcheck
blob: aa1513f5e10be709eaa8d9d17459c8f41d3cbd2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/awk -f
# Copyright (C) 2020, 2025 Tomasz Kramkowski <tk@the-tk.com>
# SDPX-License-Identifier: MIT
BEGIN { FS = "=" }
{ a[substr($1, 14)] = $2 }
END {
	if (a["STATUS"] != "Discharging") exit 0
	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
}