fix properly round battery percent

pull/93/head
romkatv 5 years ago
parent 6a1f0659e6
commit 9f05efb8e2

@ -464,7 +464,7 @@ prompt_battery() {
if _p9k_read_file $dir/(energy|charge)_now(N); then if _p9k_read_file $dir/(energy|charge)_now(N); then
(( energy_now += _P9K_RETVAL )) (( energy_now += _P9K_RETVAL ))
elif _p9k_read_file $dir/capacity(N); then elif _p9k_read_file $dir/capacity(N); then
(( energy_now += _P9K_RETVAL * full / 100 )) (( energy_now += _P9K_RETVAL * full / 100. + 0.5 ))
fi fi
_p9k_read_file $dir/status(N) && local bat_status=$_P9K_RETVAL || continue _p9k_read_file $dir/status(N) && local bat_status=$_P9K_RETVAL || continue
[[ $bat_status != Full ]] && is_full=0 [[ $bat_status != Full ]] && is_full=0
@ -474,7 +474,7 @@ prompt_battery() {
(( energy_full )) || return (( energy_full )) || return
bat_percent=$(( 100 * energy_now / energy_full )) bat_percent=$(( 100. * energy_now / energy_full + 0.5 ))
(( bat_percent > 100 )) && bat_percent=100 (( bat_percent > 100 )) && bat_percent=100
if (( is_full || bat_percent == 100 )); then if (( is_full || bat_percent == 100 )); then

Loading…
Cancel
Save