diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2020-12-30 14:20:21 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2020-12-30 14:32:50 +0000 |
commit | b927aa1d91d50887e3bb5fa4333687d8ab373828 (patch) | |
tree | b6b9bbb48027a39fadaa7cdef99348bbac607252 /battcheck | |
download | battd-b927aa1d91d50887e3bb5fa4333687d8ab373828.tar.gz battd-b927aa1d91d50887e3bb5fa4333687d8ab373828.tar.xz battd-b927aa1d91d50887e3bb5fa4333687d8ab373828.zip |
init commit
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 +} |