chargecurrent.sh 751 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. dir=/sys/class/power_supply/battery
  3. # could also be /sys/class/power_supply/axp20x-battery
  4. file1=constant_charge_current_max
  5. file2=input_current_limited
  6. # maximum current in mA from file, or default value:
  7. currmax=1000
  8. # this file is sourced and can override any of the vars above
  9. conf=/home/defaultuser/.config/chargecurrent.env
  10. [ -r $conf ] && . $conf
  11. [ "$currmax" -gt 0 ] && [ "$currmax" -le 2400 ] || exit 1
  12. cd "$dir" || exit 1
  13. printf 'Current value %s:\t' $file1
  14. cat $file1 || exit 1
  15. printf 'Current value %s: \t' $file2
  16. cat $file2 || exit 1
  17. chmod +w $file1 $file2 || exit 1
  18. echo $(($currmax * 1000)) > $file1 && echo 1 > $file2
  19. printf ' New value %s:\t' $file1
  20. cat $file1
  21. printf ' New value %s: \t' $file2
  22. cat $file2