diff --git a/install/acc.sh b/install/acc.sh index 369c604..6e68071 100644 --- a/install/acc.sh +++ b/install/acc.sh @@ -140,7 +140,6 @@ test_charging_switch() { local idleMode=false local failed=false - local testingSwitch=true chargingSwitch=($@) echo @@ -152,7 +151,7 @@ test_charging_switch() { echo "chargingSwitch=($*)" > $TMPDIR/.sw flip_sw off - $blacklisted && { + ${blacklisted:-false} && { print_blacklisted return 10 } diff --git a/install/accd.sh b/install/accd.sh index ff61364..3d42cd7 100644 --- a/install/accd.sh +++ b/install/accd.sh @@ -489,7 +489,7 @@ else local over3=false [ $# -gt 3 ] && over3=true for f in $(echo $1); do - if [ -f "$f" ] && chmod +r $f 2>/dev/null \ + if [ -f "$f" ] && chmod a+r $f 2>/dev/null \ && { ! cat $f > /dev/null 2>&1 \ || [ -z "$(cat $f 2>/dev/null)" ] \ @@ -599,7 +599,7 @@ else : > $TMPDIR/ch-volt-ctrl-files_ ls -1 $(ls_volt_ctrl_files | grep -Ev '^#|^$') 2>/dev/null | \ while read file; do - chmod +r $file 2>/dev/null && grep -Eq '^4[1-4][0-9]{2}' $file || continue + chmod a+r $file 2>/dev/null && grep -Eq '^4[1-4][0-9]{2}' $file || continue grep -q '.... ....' $file && continue echo ${file}::$(sed -n 's/^..../v/p' $file)::$(cat $file) \ >> $TMPDIR/ch-volt-ctrl-files_ @@ -613,13 +613,13 @@ else : > $TMPDIR/ch-curr-ctrl-files_ ls -1 $(ls_curr_ctrl_files_boolean | grep -Ev '^#|^$') 2>/dev/null | \ while read file; do - chmod +r $file 2>/dev/null || continue + chmod a+r $file 2>/dev/null || continue grep -q '^[01]$' $file && echo ${file}::1::0 >> $TMPDIR/ch-curr-ctrl-files done ls -1 $(ls_curr_ctrl_files_static | grep -Ev '^#|^$') 2>/dev/null | \ while read file; do - chmod +r $file 2>/dev/null || continue + chmod a+r $file 2>/dev/null || continue defaultValue=$(cat $file) [ -n "$defaultValue" ] || continue ampFactor=$(sed -n 's/^ampFactor=//p' $dataDir/config.txt 2>/dev/null) diff --git a/install/batt-interface.sh b/install/batt-interface.sh index b5f9efa..385bb36 100644 --- a/install/batt-interface.sh +++ b/install/batt-interface.sh @@ -23,17 +23,17 @@ not_charging() { tt "${chargingSwitch[$*]-}" "*\ --" || battStatusOverride= [ $currFile != $TMPDIR/.dummy-curr ] || battStatusWorkaround=false - if [ -z "${battStatusOverride-}" ] && [ "$switch" = off ]; then + if [ -z "${battStatusOverride-}" ] && [ -n "$switch" ]; then for i in $(seq $nci); do - ! status ${1-} || return 0 - [ $i = $nci ] || sleep 3 - done - return 1 - elif ! ${isAccd:-false} && [ "$switch" = on ]; then - for i in $(seq $nci); do - status ${1-} || return 1 + if [ "$switch" = off ]; then + ! status ${1-} || return 0 + else + status ${1-} || return 1 + fi + [ ! -f $TMPDIR/.nowrite ] || { rm $TMPDIR/.nowrite 2>/dev/null || :; break; } [ $i = $nci ] || sleep 3 done + [ "$switch" = on ] || return 1 else status ${1-} fi @@ -48,8 +48,8 @@ online() { read_status() { local status="$(cat $battStatus)" case "$status" in - *Charging*) printf Charging;; - *Not*) printf Idle;; + Charging|Discharging) printf %s $status;; + Not?charging) printf Idle;; *) printf Discharging;; esac } @@ -76,8 +76,6 @@ status() { _status=$(read_status) - [ -z "${exitCode_-}" ] || echo " switch:${switch:-on} current:$curThen,$curNow" - if [ -n "${battStatusOverride-}" ]; then if tt "$battStatusOverride" "Discharging|Idle"; then [ $(cat ${chargingSwitch[0]}) != ${chargingSwitch[2]} ] || _status=$battStatusOverride @@ -88,6 +86,8 @@ status() { [ $_status = Idle ] || idle_discharging fi + [ -z "${exitCode_-}" ] || echo -e " switch: ${switch:--} (${swValue:-N/A})\tcurrent: $(calc $curNow \* 1000 / ${ampFactor:-$ampFactor_} | xargs printf %.f)mA ($_status)" + for i in Discharging DischargingDischarging Idle IdleIdle; do [ $i != ${1-}$_status ] || return 0 done @@ -143,7 +143,7 @@ if ${init:-false}; then } - idleThreshold=21 # mA + idleThreshold=11 # mA ampFactor=$(sed -n 's/^ampFactor=//p' $dataDir/config.txt 2>/dev/null || :) ampFactor_=${ampFactor:-1000} diff --git a/install/read-ch-curr-ctrl-files-p2.sh b/install/read-ch-curr-ctrl-files-p2.sh index 3565a64..5c3f60a 100644 --- a/install/read-ch-curr-ctrl-files-p2.sh +++ b/install/read-ch-curr-ctrl-files-p2.sh @@ -14,7 +14,7 @@ then ls -1 $(ls_curr_ctrl_files_dynamic | grep -Ev '^#|^$') 2>/dev/null | \ while read file; do - chmod +r $file || continue + chmod a+r $file || continue defaultValue=$(cat $file) [ -n "$defaultValue" ] || continue [ $defaultValue -eq 0 ] && continue diff --git a/install/set-ch-curr.sh b/install/set-ch-curr.sh index 82fb518..3d2ca5f 100644 --- a/install/set-ch-curr.sh +++ b/install/set-ch-curr.sh @@ -40,8 +40,7 @@ set_ch_curr() { apply_current() { eval " - if [ $1 -ne 0 ] - then + if [ $1 -ne 0 ]; then maxChargingCurrent=($1 $(sed "s|::v|::$1|" $TMPDIR/ch-curr-ctrl-files)) else maxChargingCurrent=($1 $(sed "s|::v.*::|::$1::|" $TMPDIR/ch-curr-ctrl-files)) @@ -50,7 +49,6 @@ set_ch_curr() { && unset max_charging_current mcc \ && apply_on_plug \ && { - #noEcho=true ! $verbose || print_curr_set $1 } || return 1 } diff --git a/install/set-ch-volt.sh b/install/set-ch-volt.sh index 4e2f577..c3429ed 100644 --- a/install/set-ch-volt.sh +++ b/install/set-ch-volt.sh @@ -20,7 +20,6 @@ set_ch_volt() { && unset max_charging_voltage mcv \ && apply_on_boot \ && { - #noEcho=true ! ${verbose:-true} || print_volt_set $1 } || return 1 }