Skip to content

Commit

Permalink
tlp chargeonce: better explain the process in the output
Browse files Browse the repository at this point in the history
Reference:
* #773
  • Loading branch information
linrunner committed Jan 12, 2025
1 parent a73ec46 commit b047aee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions bat.d/05-thinkpad
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,13 @@ batdrv_chargeonce () {
return 3
fi

printf "Current charge level of battery %s is %s%%, we are about to charge to %s%%.\n" "$_bat_str" "$soc" "$cur_stop" 1>&2
printf "Setting temporary charge threshold for battery %s:\n" "$_bat_str" 1>&2
write_sysf "$temp_start" "$_bf_start" || rc=5
if [ $rc -eq 0 ]; then
printf " start = %3d\n" "$temp_start" 1>&2
cprintf "notice" "Charging start now, keep the charger connected.\n" 1>&2
printf "If charging does not start immediately, unplug the charger for a moment and reconnect it.\n" 1>&2
else
cprintf "err" " start = %3d (Error: write failed)\n" "$temp_start" 1>&2
fi
Expand Down
2 changes: 2 additions & 0 deletions bat.d/10-thinkpad-legacy
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ batdrv_chargeonce () {
return 3
fi

printf "Current charge level of battery %s is %s%%, we are about to charge to %s%%.\n" "$_bat_str" "$soc" "$cur_stop" 1>&2
printf "Setting temporary charge threshold for battery %s:" "$_bat_str" 1>&2
case $_bm_thresh in
tpsmapi)
Expand All @@ -565,6 +566,7 @@ batdrv_chargeonce () {

if [ $rc -eq 0 ]; then
printf " start = %3d\n" "$temp_start" 1>&2
cprintf "notice" "Charging starts now, keep the charger connected.\n" 1>&2
else
cprintf "err" " start = %3d (Error: write failed)\n" "$temp_start" 1>&2
fi
Expand Down
2 changes: 2 additions & 0 deletions bat.d/55-cros-ec
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,12 @@ batdrv_chargeonce () {
return 3
fi

printf "Current charge level of battery %s is %s%%, we are about to charge to %s%%.\n" "$_bat_str" "$soc" "$cur_stop" 1>&2
printf "Setting temporary charge threshold for battery %s:\n" "$_bat_str" 1>&2
write_sysf "$temp_start" "$_bf_start" || rc=5
if [ $rc -eq 0 ]; then
printf " start = %3d\n" "$temp_start" 1>&2
cprintf "notice" "Charging starts now, keep the charger connected.\n" 1>&2
else
cprintf "err" " start = %3d (Error: write failed)\n" "$temp_start" 1>&2
fi
Expand Down
3 changes: 0 additions & 3 deletions tlp.in
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,6 @@ case "$_cmd" in
# shellcheck disable=SC2086
chargeonce_battery "$_carg1"
exitcode=$?
if [ $exitcode -eq 0 ]; then
cecho "Charging starts now, keep AC connected." "notice" 1>&2
fi
else
exitcode=2
fi
Expand Down

0 comments on commit b047aee

Please sign in to comment.