aboutsummaryrefslogtreecommitdiff
path: root/dwmblocks.c
diff options
context:
space:
mode:
authorAidan <torrinfail@gmail.com>2019-11-04 15:34:34 -0700
committerAidan <torrinfail@gmail.com>2019-11-04 15:34:34 -0700
commit3da92ebccb863394a3501ce2d9cbe60ad9aafc8c (patch)
tree5f5aa1b0656a33aa36804ed40a7f468a4653ff50 /dwmblocks.c
parent690475e1e52be120e49f053982249be5ccc59177 (diff)
downloaddwmblocks-3da92ebccb863394a3501ce2d9cbe60ad9aafc8c.tar.gz
dwmblocks-3da92ebccb863394a3501ce2d9cbe60ad9aafc8c.tar.bz2
dwmblocks-3da92ebccb863394a3501ce2d9cbe60ad9aafc8c.zip
Changed delimeter to accept multiple characters.
Diffstat (limited to 'dwmblocks.c')
-rw-r--r--dwmblocks.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/dwmblocks.c b/dwmblocks.c
index 2db3489..76e7377 100644
--- a/dwmblocks.c
+++ b/dwmblocks.c
@@ -56,13 +56,20 @@ void getcmd(const Block *block, char *output)
return;
//int N = strlen(output);
char c;
- int i = strlen(block->icon);
+ int sl;
+ int i = sl = 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)
@@ -104,7 +111,8 @@ void getstatus(char *str)
{
strcpy(str + j, statusbar[i]);
}
- str[--j] = '\0';
+ for (int i = 0; delim[i]; i++)
+ str[--j] = '\0';
}
@@ -159,7 +167,7 @@ int main(int argc, char** argv)
for(int i = 0; i < argc; i++)
{
if (!strcmp("-d",argv[i]))
- delim = argv[++i][0];
+ delim = argv[++i];
}
signal(SIGTERM, termhandler);
signal(SIGINT, termhandler);