diff options
| -rwxr-xr-x | battery | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1,7 +1,19 @@ #!/bin/sh -report=$(acpi | tr -d ',') -status=$(echo $report | cut -d\ -f 3 | cut -b 1) -perc=$(echo $report | cut -d\ -f 4) -time=$(echo $report | cut -d\ -f 5 | sed 's/\([0-9]*\):\([0-9]*\).*/\1h\2m/') -echo $status$perc $time +awk 'BEGIN { status = ""; efull = 0; enow = 1; pnow = 1; FS="="; } +/POWER_SUPPLY_STATUS/ { status = $2; } +/POWER_SUPPLY_ENERGY_FULL=/ { efull = $2; } +/POWER_SUPPLY_ENERGY_NOW/ { enow = $2; } +/POWER_SUPPLY_POWER_NOW/ { pnow = $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 |
