all repos — slstatus @ 50219004d6a631b156be04e4ce4b235622a6db93

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

return n/a instead of exiting if a specific value cannot be read
Daniel Walter d.walter@0x90.at
Thu, 10 Mar 2016 13:09:24 +0100
commit

50219004d6a631b156be04e4ce4b235622a6db93

parent

b51721c65a8ec2067c599c076d2db6b4a29f567a

1 files changed, 11 insertions(+), 11 deletions(-)

jump to
M slstatus.cslstatus.c

@@ -79,7 +79,7 @@

/* open battery now file */ if (!(fp = fopen(batterynowfile, "r"))) { fprintf(stderr, "Error opening battery file."); - exit(1); + return smprintf("n/a"); } /* read value */

@@ -91,7 +91,7 @@

/* open battery full file */ if (!(fp = fopen(batteryfullfile, "r"))) { fprintf(stderr, "Error opening battery file."); - exit(1); + return smprintf("n/a"); } /* read value */

@@ -117,7 +117,7 @@

/* open temperature file */ if (!(fp = fopen(tempfile, "r"))) { fprintf(stderr, "Could not open temperature file.\n"); - exit(1); + return smprintf("n/a"); } /* extract temperature */

@@ -141,7 +141,7 @@

/* open stat file */ if (!(fp = fopen("/proc/stat","r"))) { fprintf(stderr, "Error opening stat file."); - exit(1); + return smprintf("n/a"); } /* read values */

@@ -156,7 +156,7 @@

/* open stat file */ if (!(fp = fopen("/proc/stat","r"))) { fprintf(stderr, "Error opening stat file."); - exit(1); + return smprintf("n/a"); } /* read values */

@@ -183,8 +183,8 @@

/* get time in format */ time(&tm); if(!strftime(buf, bufsize, timeformat, localtime(&tm))) { - fprintf(stderr, "Strftime failed.\n"); - exit(1); + fprintf(stderr, "Strftime failed.\n"); + return smprintf("n/a"); } /* return time */

@@ -202,7 +202,7 @@

/* open meminfo file */ if (!(fp = fopen("/proc/meminfo", "r"))) { fprintf(stderr, "Error opening meminfo file."); - exit(1); + return smprintf("n/a"); } /* read the values */

@@ -283,7 +283,7 @@

/* open wifi file */ if(!(fp = fopen(path, "r"))) { fprintf(stderr, "Error opening wifi operstate file."); - exit(1); + return smprintf("n/a"); } /* read the status */

@@ -294,13 +294,13 @@ fclose(fp);

/* check if interface down */ if(strcmp(status, "up\n") != 0){ - return "n/a"; + return smprintf("n/a"); } /* open wifi file */ if (!(fp = fopen("/proc/net/wireless", "r"))) { fprintf(stderr, "Error opening wireless file."); - exit(1); + return smprintf("n/a"); } /* extract the signal strength */