From 65b46c79813b65a566e07150de39b4cc000c6f07 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sun, 31 Oct 2021 21:59:10 -0300 Subject: [PATCH] set-battery-threshold --- .local/bin/set-battery-threshold | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 .local/bin/set-battery-threshold diff --git a/.local/bin/set-battery-threshold b/.local/bin/set-battery-threshold new file mode 100755 index 0000000..40774ae --- /dev/null +++ b/.local/bin/set-battery-threshold @@ -0,0 +1,23 @@ +#!/bin/sh + +# https://www.coreboot.org/Board:lenovo/x230 + +usage () { + echo "usage: $0 start_threshold stop_threshold" + exit 1 +} + +if expr "$1" : '[0-9][0-9]*$'>/dev/null; then + start_threshold="$(printf '%x' "$1")" +else + usage +fi + +if expr "$2" : '[0-9][0-9]*$'>/dev/null; then + stop_threshold="$(printf '%x' "$2")" +else + usage +fi + +ectool -w 0xb0 -z "$start_threshold" +ectool -w 0xb1 -z "$stop_threshold"