]> git.armaanb.net Git - dwmblocks.git/commitdiff
Remove delimiter option
authorArmaan Bhojwani <me@armaanb.net>
Mon, 21 Jun 2021 17:05:57 +0000 (13:05 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Mon, 21 Jun 2021 17:05:57 +0000 (13:05 -0400)
config.h
dwmblocks.c

index bb4903aa239f22850f691b60970d7cae0a8f6194..79b6ead96538f7f2dde7d670e86cb5c47ec8a2f5 100644 (file)
--- a/config.h
+++ b/config.h
@@ -4,8 +4,3 @@ static const Block blocks[] = {
        {"[VOL: ", "amixer sget Master | awk -F'[][]' '/dB/ { print $2 \", \" $6 \"]\"}'", 15, 10},
        {"[DAT: ", "date '+%A %Y-%m-%d %I:%M:%S %p]'", 1, 0},
 };
-
-/* sets delimeter between status commands. NULL character ('\0') means
- * no delimeter. */
-static char delim[] = " ";
-static unsigned int delimLen = 1;
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();