diff options
| author | tslil clingman <> | 2023-12-14 20:21:14 +0100 |
|---|---|---|
| committer | tslil clingman <> | 2023-12-14 20:21:14 +0100 |
| commit | 7e94caf6d63fcf327f40a3f359f222dc17d3bc7e (patch) | |
| tree | 619d6fe942ae9f7256f4515d5fe2ba90c8bfb6a3 | |
| parent | 952c39a529ed6ec812810f7dfd7ff18a8d3b1537 (diff) | |
battery: if charging use (q_full - q_now)/i_now for time
| -rwxr-xr-x | battery | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,14 +1,16 @@ #!/bin/sh -awk 'BEGIN { status = ""; q_now = 0; i_now = 1; perc = 0; FS="="; } +awk 'BEGIN { status = ""; q_now = 0; q_full = 0; i_now = 1; perc = 0; FS="="; } /POWER_SUPPLY_STATUS/ { status = $2; } /POWER_SUPPLY_CURRENT_NOW=/ { i_now = $2; } /POWER_SUPPLY_CHARGE_NOW/ { q_now = $2; } +/POWER_SUPPLY_CHARGE_FULL/ { q_full = $2; } /POWER_SUPPLY_CAPACITY=/ { perc = $2; } END { if (status=="Full"||status=="Unknown") { print status } else { - h=q_now/i_now; + if (status=="Charging") {q = q_full - q_now} else {q = q_now}; + h=q/i_now; m=(h-int(h))*60; printf("%s%d%% %dh%dm\n", substr(status, 0, 1), |
