]> git.armaanb.net Git - dwmblocks.git/blobdiff - dwmblocks.c
Fixed issue with empty command delimiter
[dwmblocks.git] / dwmblocks.c
index b6f696ff745162a907f296c5f8a04d1d528f6a0f..c66dbc794b6d61f0054903077dbc63a9751088fa 100644 (file)
@@ -56,6 +56,8 @@ void getcmd(const Block *block, char *output)
        int i = strlen(block->icon);
        fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
        i = strlen(output);
+       if (i == 0)//return if block and command output are both empty
+               return;
        if (delim[0] != '\0') {
                //only chop off newline if one is present at the end
                i = output[i-1] == '\n' ? i-1 : i;
@@ -178,7 +180,8 @@ int main(int argc, char** argv)
                else if (!strcmp("-p",argv[i]))
                        writestatus = pstdout;
        }
-       delim[MIN(delimLen, strlen(delim))] = '\0';
+       delimLen = MIN(delimLen, strlen(delim));
+       delim[delimLen++] = '\0';
        signal(SIGTERM, termhandler);
        signal(SIGINT, termhandler);
        statusloop();