Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Return actual percentage for wifi_perc()
[slstatus.git]
/
components
/
wifi.c
diff --git
a/components/wifi.c
b/components/wifi.c
index
30b57ab
..
9ecb8e1
100644
(file)
--- a/
components/wifi.c
+++ b/
components/wifi.c
@@
-14,7
+14,9
@@
const char *
wifi_perc(const char *iface)
{
const char *
wifi_perc(const char *iface)
{
- int i, perc;
+ int i, cur;
+ float perc;
+ int total = 70; /* the max of /proc/net/wireless */
char *p, *datastart;
char path[PATH_MAX];
char status[5];
char *p, *datastart;
char path[PATH_MAX];
char status[5];
@@
-50,9
+52,11
@@
wifi_perc(const char *iface)
return NULL;
datastart = (datastart+(strlen(iface)+1));
return NULL;
datastart = (datastart+(strlen(iface)+1));
- sscanf(datastart + 1, " %*d %d %*d %*d %*d %*d %*d %*d %*d %*d", &
perc
);
+ sscanf(datastart + 1, " %*d %d %*d %*d %*d %*d %*d %*d %*d %*d", &
cur
);
- return bprintf("%d", perc);
+ perc = (float)cur / total * 100.0;
+
+ return bprintf("%.0f", perc);
}
const char *
}
const char *