slstatus

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

entropy.c (573B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "../slstatus.h"
      3 #if defined(__linux__)
      4 	#include <stdint.h>
      5 	#include <stdio.h>
      6 
      7 	#include "../util.h"
      8 
      9 	#define ENTROPY_AVAIL "/proc/sys/kernel/random/entropy_avail"
     10 
     11 	const char *
     12 	entropy(const char *unused)
     13 	{
     14 		uintmax_t num;
     15 
     16 		if (pscanf(ENTROPY_AVAIL, "%ju", &num) != 1)
     17 			return NULL;
     18 
     19 		return bprintf("%ju", num);
     20 	}
     21 #elif defined(__OpenBSD__) | defined(__FreeBSD__)
     22 	const char *
     23 	entropy(const char *unused)
     24 	{
     25 		/* Unicode Character 'INFINITY' (U+221E) */
     26 		return "\xe2\x88\x9e";
     27 	}
     28 #endif