aboutsummaryrefslogtreecommitdiffstats
path: root/battcheck
blob: 4a6ce1fc90cbf08883432dc1102e2f6c7b9046a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/awk -f
# Copyright (C) 2020 Tomasz Kramkowski <tk@the-tk.com>
# 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 (min_pct && a["CAPACITY"] < min_pct) exit 1
	exit 0
}