summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbattery30
1 files changed, 15 insertions, 15 deletions
diff --git a/battery b/battery
index 250f81f..f6db0b9 100755
--- a/battery
+++ b/battery
@@ -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