diff options
Diffstat (limited to 'battcheck')
-rwxr-xr-x | battcheck | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/battcheck b/battcheck new file mode 100755 index 0000000..4a6ce1f --- /dev/null +++ b/battcheck @@ -0,0 +1,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 +} |