From cde090c491b6193813788b8e3b883a03de7d1e03 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Mon, 21 Jun 2021 13:05:57 -0400 Subject: [PATCH] Remove delimiter option --- config.h | 5 ----- dwmblocks.c | 19 +++++-------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/config.h b/config.h index bb4903a..79b6ead 100644 --- 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; diff --git a/dwmblocks.c b/dwmblocks.c index 667a8e4..e6c20dd 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -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(); -- 2.39.2