2 # Copyright (C) 2011 Henning Schild <henning@wh9.tu-dresden.de>
3 # Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
5 # Distributed under the terms of the GNU General Public License, v2 or later
9 SMAPI_SYSFS="/sys/devices/platform/smapi"
20 ebegin "Making sure that module 'tp_smapi' is loaded"
25 ebegin "Checking for \"${SMAPI_SYSFS}\""
26 test -d "${SMAPI_SYSFS}"
30 if [ "${state1}" -ne "0" ] || [ "${state2}" -ne "0" ]; then
34 ebegin "Starting ${SVCNAME}"
35 set_all ${SMAPI_THRESH_START} ${SMAPI_THRESH_STOP}
40 einfo "Nothing required to be done to stop ${SVCNAME}"
44 if ! service_started; then
45 "${RC_SERVICE}" start || return $?
52 einfo "Switching ${SVCNAME} to high thesholds"
53 set_all ${SMAPI_HIGH_THRESH_START} ${SMAPI_HIGH_THRESH_STOP}
59 einfo "Switching ${SVCNAME} to low thesholds"
60 set_all ${SMAPI_LOW_THRESH_START} ${SMAPI_LOW_THRESH_STOP}
68 for bat in ${BATS}; do
69 ebegin " setting thresholds for ${bat}: $tstart $tstop"
70 echo ${tstart} > ${SMAPI_SYSFS}/${bat}/start_charge_thresh
71 echo ${tstop} > ${SMAPI_SYSFS}/${bat}/stop_charge_thresh
84 for bat in ${BATS}; do
85 tstart=$(cat ${SMAPI_SYSFS}/${bat}/start_charge_thresh)
86 tstop=$(cat ${SMAPI_SYSFS}/${bat}/stop_charge_thresh)
87 if [ "$(cat ${SMAPI_SYSFS}/${bat}/installed)" -eq "1" ]; then
88 presence=" [installed]"
90 einfo "${bat}: ${tstart} ${tstop}${presence}"