blob: f6db0b9fabf89965766d74a59b73d6601870d278 (
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 = ""; q_now = 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_CAPACITY=/ { perc = $2; }
END { if (status=="Full"||status=="Unknown") {
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
|