all repos — slstatus @ 5a943fa59cab43f4a2cf6c133c4ef5676d6358b1

my build of slstatus (tools.suckless.org/slstatus/)

added entropy
Aaron Marcher info@nulltime.net
Fri, 03 Jun 2016 13:04:15 +0200
commit

5a943fa59cab43f4a2cf6c133c4ef5676d6358b1

parent

bf2cdd102e33272cbac7e886fdc8e4999002e1e4

3 files changed, 26 insertions(+), 0 deletions(-)

jump to
M config.def.hconfig.def.h

@@ -16,6 +16,7 @@ - battery_perc (battery percentage) [argument: battery name]

- cpu_perc (cpu usage in percent) [argument: NULL] - datetime (date and time) [argument: format] - disk_perc (disk usage in percent) [argument: mountpoint] +- entropy (available entropy) [argument: NULL] - ram_perc (ram usage in percent) [argument: NULL] - temp (temperature in degrees) [argument: temperature file] - vol_perc (alsa volume and mute status in percent) [argument: soundcard]

@@ -29,5 +30,6 @@ { temp, "%3s | ", "/sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input" },

{ ram_perc, "ram %3s | ", NULL }, { vol_perc, "vol %4s | ", "default" }, { disk_perc, "ssd %3s | ", "/" }, + { entropy, "crypt %s | ", NULL }, { datetime, "%s", "%y-%m-%d %H:%M:%S" }, };
M slstatus.cslstatus.c

@@ -181,6 +181,29 @@ /* return perc */

return smprintf("%d%%", perc); } +/* entropy available */ +char * +entropy(const char *null) +{ + int entropy = 0; + FILE *fp; + + /* open entropy file */ + if (!(fp = fopen("/proc/sys/kernel/random/entropy_avail", "r"))) { + fprintf(stderr, "Could not open entropy file.\n"); + return smprintf("n/a"); + } + + /* extract entropy */ + fscanf(fp, "%d", &entropy); + + /* close entropy file */ + fclose(fp); + + /* return entropy */ + return smprintf("%d", entropy); +} + /* ram percentage */ char * ram_perc(const char *null)
M slstatus.hslstatus.h

@@ -18,6 +18,7 @@ char *battery_perc(const char *);

char *cpu_perc(const char *); char *datetime(const char *); char *disk_perc(const char *); +char *entropy(const char*); char *ram_perc(const char *); char *temp(const char *); char *vol_perc(const char *);