aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan <torrinfail@gmail.com>2019-11-07 13:07:19 -0700
committerAidan <torrinfail@gmail.com>2019-11-07 13:07:19 -0700
commit72dc44f963bfdfbef141cbba9cf23f1358a335a3 (patch)
tree14dd61792c8e4ad0a42c6056f3421f04fd413145
parent3da92ebccb863394a3501ce2d9cbe60ad9aafc8c (diff)
downloaddwmblocks-72dc44f963bfdfbef141cbba9cf23f1358a335a3.tar.gz
dwmblocks-72dc44f963bfdfbef141cbba9cf23f1358a335a3.tar.bz2
dwmblocks-72dc44f963bfdfbef141cbba9cf23f1358a335a3.zip
Revert "Changed delimeter to accept multiple characters."
Bug was found where certain modules caused dwm to lag horribly. Reverting until a fix can be found. This reverts commit 3da92ebccb863394a3501ce2d9cbe60ad9aafc8c.
-rw-r--r--blocks.h4
-rw-r--r--dwmblocks.c20
2 files changed, 8 insertions, 16 deletions
diff --git a/blocks.h b/blocks.h
index 3493ce1..31e98af 100644
--- a/blocks.h
+++ b/blocks.h
@@ -16,5 +16,5 @@ static const Block blocks[] = {
{"", "~/bin/statusbar/clock", 5, 0},
};
-//sets delimeter between status commands. Empty string ("") means no delimeter.
-static char* delim = "|";
+//sets delimeter between status commands. NULL character ('\0') means no delimeter.
+static char delim = '|';
diff --git a/dwmblocks.c b/dwmblocks.c
index 76e7377..2db3489 100644
--- a/dwmblocks.c
+++ b/dwmblocks.c
@@ -56,20 +56,13 @@ void getcmd(const Block *block, char *output)
return;
//int N = strlen(output);
char c;
- int sl;
- int i = sl = strlen(block->icon);
+ int i = strlen(block->icon);
while((c = fgetc(cmdf)) != EOF)
output[i++] = c;
+ if (delim != '\0' && --i)
+ output[i++] = delim;
+ output[i++] = '\0';
pclose(cmdf);
- if (i == sl) { //return empty string if command has no output
- output[0] = '\0';
- return;
- }
- if (delim[0] != '\0' && --i)
- for (int j = 0; delim[j]; j++)
- output[i++] = delim[j];
- else
- output[--i] = '\0';
}
void getcmds(int time)
@@ -111,8 +104,7 @@ void getstatus(char *str)
{
strcpy(str + j, statusbar[i]);
}
- for (int i = 0; delim[i]; i++)
- str[--j] = '\0';
+ str[--j] = '\0';
}
@@ -167,7 +159,7 @@ int main(int argc, char** argv)
for(int i = 0; i < argc; i++)
{
if (!strcmp("-d",argv[i]))
- delim = argv[++i];
+ delim = argv[++i][0];
}
signal(SIGTERM, termhandler);
signal(SIGINT, termhandler);