slstatus

status monitor
git clone git://git.suckless.org/slstatus
Log | Files | Refs | README | LICENSE

load_avg.c (375B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 
      5 #include "../slstatus.h"
      6 #include "../util.h"
      7 
      8 const char *
      9 load_avg(const char *unused)
     10 {
     11 	double avgs[3];
     12 
     13 	if (getloadavg(avgs, 3) < 0) {
     14 		warn("getloadavg: Failed to obtain load average");
     15 		return NULL;
     16 	}
     17 
     18 	return bprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
     19 }