diff options
Diffstat (limited to 'src/config_swap.c')
-rw-r--r-- | src/config_swap.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/config_swap.c b/src/config_swap.c index c8469d5..090117f 100644 --- a/src/config_swap.c +++ b/src/config_swap.c @@ -29,16 +29,11 @@ void load_swap_key(struct node* n, char* key, char* val) { } int config_swap_load(struct node* n) { - long total; - long free; + struct sysinfo si; int percent; - FILE* fd = fopen("/proc/meminfo", "r"); - fscanf(fd, "SwapTotal: %ld kB ", &total); - fscanf(fd, "SwapFree: %ld kB ", &free); - fclose(fd); - - percent = (total - free) * 100 / total; + sysinfo(&si); + percent = (si.totalswap - si.freeswap) * 100 / si.totalswap; if(percent < 20) { strcpy(n->color, C_GREEN); @@ -52,7 +47,9 @@ int config_swap_load(struct node* n) { strcpy(n->label_color, C_LGREY); if(strcmp(n->display, "bar") == 0) { - print_bar(n->width, (double)(total - free) / total, n->text); + print_bar(n->width, + (double)(si.totalswap - si.freeswap) / si.totalswap, + n->text); } else { sprintf(n->text, "%02d%%", percent); } |