aux/acpi: make it stats(8)-friendly

This commit is contained in:
ftrvxmtrx 2016-10-24 23:50:04 +02:00
parent 234137bce3
commit 1f3600c83f

View file

@ -21,7 +21,6 @@ struct Batstat {
struct Battery { struct Battery {
char *unit; char *unit;
void *bst; void *bst;
int id;
int fullcharge; int fullcharge;
int capacity; int capacity;
int capacitywarn; int capacitywarn;
@ -117,7 +116,6 @@ enumbat(void *dot, void *)
b->voltage = amlint(rr[4]); b->voltage = amlint(rr[4]);
b->capacitywarn = amlint(rr[5]); b->capacitywarn = amlint(rr[5]);
b->capacitylow = amlint(rr[6]); b->capacitylow = amlint(rr[6]);
b->id = amlint(amlwalk(dot, "^_UID"));
b->bst = amlwalk(dot, "^_BST"); b->bst = amlwalk(dot, "^_BST");
if(b->bst != nil){ if(b->bst != nil){
amltake(b->bst); amltake(b->bst);
@ -213,8 +211,8 @@ batteryread(Req *r)
s -= 60*(s/60); s -= 60*(s/60);
} }
x = bats[n].fullcharge > 0 ? st.capacity * 100 / bats[n].fullcharge : -1; x = bats[n].fullcharge > 0 ? st.capacity * 100 / bats[n].fullcharge : -1;
p += snprint(p, ep-p, "%d %d %s %d %d %d %d %d %s %d %d %02d:%02d:%02d %s\n", p += snprint(p, ep-p, "%d %s %d %d %d %d %d %s %d %d %02d:%02d:%02d %s\n",
n, x, x,
bats[n].unit, st.capacity, b->fullcharge, b->capacity, b->capacitywarn, b->capacitylow, bats[n].unit, st.capacity, b->fullcharge, b->capacity, b->capacitywarn, b->capacitylow,
"mV", st.voltage, b->voltage, "mV", st.voltage, b->voltage,
h, m, s, h, m, s,
@ -231,7 +229,7 @@ tmpread(Req *r)
{ {
char buf[32], *ep, *p; char buf[32], *ep, *p;
void *er; void *er;
int n, t, cpu; int n, t;
p = buf; p = buf;
ep = buf + sizeof(buf); ep = buf + sizeof(buf);
@ -240,10 +238,7 @@ tmpread(Req *r)
t = 0; t = 0;
if(amleval(therms[n].tmp, "", &er) >= 0) if(amleval(therms[n].tmp, "", &er) >= 0)
t = amlint(er); t = amlint(er);
for(cpu = 0; cpu < 32; cpu++){ p += snprint(p, ep-p, "%d\n", (t - 2732)/10);
if(therms[n].cpus & (1<<cpu))
p += snprint(p, ep-p, "%d %d\n", cpu, (t - 2732)/10);
}
} }
readstr(r, buf); readstr(r, buf);