blob: 250f81f409a28bafe5a007027652308cb5089772 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/bin/sh
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
|