aboutsummaryrefslogtreecommitdiff
path: root/limbat
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-05-12 17:45:31 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-05-12 17:45:31 -0300
commit06887fc003755e2bdae34cb685acf285db22c6a9 (patch)
tree5cbd27ff5f025e55206296e3d18d7497c7710b5a /limbat
parent2bb9841434e3be1e1735c7b024c4d0572935f639 (diff)
downloadscripts-06887fc003755e2bdae34cb685acf285db22c6a9.tar.gz
scripts-06887fc003755e2bdae34cb685acf285db22c6a9.tar.bz2
Adding limbat
Diffstat (limited to 'limbat')
-rwxr-xr-xlimbat60
1 files changed, 60 insertions, 0 deletions
diff --git a/limbat b/limbat
new file mode 100755
index 0000000..5541d05
--- /dev/null
+++ b/limbat
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+function usage() {
+ echo "Usage: ${0} [--help | option]"
+ echo "Options are:"
+ echo " show show current charge thresholds."
+ echo " limit start charging at 30% and stop at 85%."
+ echo " normal start charging at 96% and stop at 100%."
+ exit ${1}
+}
+
+# validate command line options
+if [[ (${#} -eq 1 \
+ && "${1}" != "--help" \
+ && "${1}" != "normal" \
+ && "${1}" != "limit" \
+ && ${1} != "show") ]]; then
+ usage 1
+fi
+
+# show help
+if [ "${1}" == "--help" ]; then
+ usage 0
+fi
+
+# get action
+action="show"
+if [ "${1}" != "" ]; then
+ action=${1}
+fi
+
+function show_thresholds() {
+ echo -n "Low threshold: "
+ cat /sys/devices/platform/smapi/BAT0/start_charge_thresh
+ echo -n "High threshold: "
+ cat /sys/devices/platform/smapi/BAT0/stop_charge_thresh
+}
+
+function set_thresholds() {
+ START_THRESH=${1}
+ STOP_THRESH=${2}
+ sudo sh -c "echo ${START_THRESH} > /sys/devices/platform/smapi/BAT0/start_charge_thresh"
+ sudo sh -c "echo ${STOP_THRESH} > /sys/devices/platform/smapi/BAT0/stop_charge_thresh"
+}
+
+# do your thang
+sudo modprobe tp_smapi
+
+THRESHOLDS=""
+if [ "${action}" == "normal" ]; then
+ THRESHOLDS="96 100"
+elif [ "${action}" == "limit" ]; then
+ THRESHOLDS="30 85"
+fi
+
+if [ ! -z "${THRESHOLDS}" ]; then
+ set_thresholds ${THRESHOLDS}
+fi
+
+show_thresholds