diff options
| author | tslil clingman <> | 2023-12-14 20:15:27 +0100 |
|---|---|---|
| committer | tslil clingman <> | 2023-12-14 20:15:27 +0100 |
| commit | e037fd31e144d1e76f2c96f9ce9b108711dda800 (patch) | |
| tree | a4aa95bfdf20e6f80508f66f8d140064caaa4690 /battery | |
| parent | ceeee016acc0996051bb7932515b44c9b8528829 (diff) | |
battery: fix for laptop
Diffstat (limited to 'battery')
| -rwxr-xr-x | battery | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -1,19 +1,19 @@ #!/bin/sh -awk 'BEGIN { status = ""; efull = 0; enow = 1; pnow = 1; FS="="; } +awk 'BEGIN { status = ""; q_now = 0; i_now = 1; perc = 0; FS="="; } /POWER_SUPPLY_STATUS/ { status = $2; } -/POWER_SUPPLY_ENERGY_FULL=/ { efull = $2; } -/POWER_SUPPLY_ENERGY_NOW/ { enow = $2; } -/POWER_SUPPLY_POWER_NOW/ { pnow = $2; } +/POWER_SUPPLY_CURRENT_NOW=/ { i_now = $2; } +/POWER_SUPPLY_CHARGE_NOW/ { q_now = $2; } +/POWER_SUPPLY_CAPACITY=/ { perc = $2; } END { if (status=="Full"||status=="Unknown") { - print status - } else { - h=enow/pnow; - m=(h-int(h))*60; - printf("%s%d%% %dh%dm\n", - substr(status, 0, 1), - enow/efull*100.0, - h, m); - } - }' \ - /sys/class/power_supply/BAT0/uevent + print status + } else { + h=q_now/i_now; + m=(h-int(h))*60; + printf("%s%d%% %dh%dm\n", + substr(status, 0, 1), + perc, + h, m); + } + }' \ + /sys/class/power_supply/BAT1/uevent |
