]> git.armaanb.net Git - dwmblocks.git/blobdiff - dwmblocks.c
Reduce refresh time
[dwmblocks.git] / dwmblocks.c
index 667a8e4901ca6e873ebd3a2a7db9dd4ce4e11ef1..e6c20dd37d44a682a80cda47c56afd2079abfaae 100644 (file)
@@ -63,20 +63,15 @@ void getcmd(const Block *block, char *output)
        if (!cmdf)
                return;
        int i = strlen(block->icon);
-       fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
+       fgets(output+i, CMDLENGTH-i, cmdf);
        i = strlen(output);
        if (i == 0) {
                //return if block and command output are both empty
                pclose(cmdf);
                return;
+       } else if (output[i-1] == '\n') {
+               output[i-1] = '\0';
        }
-       if (delim[0] != '\0') {
-               //only chop off newline if one is present at the end
-               i = output[i-1] == '\n' ? i-1 : i;
-               strncpy(output+i, delim, delimLen); 
-       }
-       else
-               output[i++] = '\0';
        pclose(cmdf);
 }
 
@@ -121,7 +116,7 @@ int getstatus(char *str, char *last)
        str[0] = '\0';
        for (unsigned int i = 0; i < LENGTH(blocks); i++)
                strcat(str, statusbar[i]);
-       str[strlen(str)-strlen(delim)] = '\0';
+       str[strlen(str)] = '\0';
        return strcmp(str, last);//0 if they are the same
 }
 
@@ -192,17 +187,13 @@ void termhandler()
 int main(int argc, char** argv)
 {
        for (int i = 0; i < argc; i++) {//Handle command line arguments
-               if (!strcmp("-d",argv[i]))
-                       strncpy(delim, argv[++i], delimLen);
-               else if (!strcmp("-p",argv[i]))
+               if (!strcmp("-p",argv[i]))
                        writestatus = pstdout;
        }
 #ifndef NO_X
        if (!setupX())
                return 1;
 #endif
-       delimLen = MIN(delimLen, strlen(delim));
-       delim[delimLen++] = '\0';
        signal(SIGTERM, termhandler);
        signal(SIGINT, termhandler);
        statusloop();