slstatus

Fork of suckless' slstatus with my personal patches
git clone https://git.instinctive.eu/slstatus.git
Log | Files | Refs | README | LICENSE

entropy.c (617B)


      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 		// https://www.unicode.org/charts/PDF/U2200.pdf
     26 		/* Unicode Character 'INFINITY' (U+221E) */
     27 		return "\u221E";
     28 	}
     29 #endif