pinosaur
/
dwmblocks.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
690475e
)
Changed delimeter to accept multiple characters.
author
Aidan
<torrinfail@gmail.com>
Mon, 4 Nov 2019 22:34:34 +0000
(15:34 -0700)
committer
Aidan
<torrinfail@gmail.com>
Mon, 4 Nov 2019 22:34:34 +0000
(15:34 -0700)
blocks.h
patch
|
blob
|
history
dwmblocks.c
patch
|
blob
|
history
diff --git
a/blocks.h
b/blocks.h
index
31e98af
..
3493ce1
100644
(file)
--- a/
blocks.h
+++ b/
blocks.h
@@
-16,5
+16,5
@@
static const Block blocks[] = {
{"", "~/bin/statusbar/clock", 5, 0},
};
{"", "~/bin/statusbar/clock", 5, 0},
};
-//sets delimeter between status commands.
NULL character ('\0'
) means no delimeter.
-static char
delim = '|'
;
+//sets delimeter between status commands.
Empty string (""
) means no delimeter.
+static char
* delim = "|"
;
diff --git
a/dwmblocks.c
b/dwmblocks.c
index
2db3489
..
76e7377
100644
(file)
--- a/
dwmblocks.c
+++ b/
dwmblocks.c
@@
-56,13
+56,20
@@
void getcmd(const Block *block, char *output)
return;
//int N = strlen(output);
char c;
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;
while((c = fgetc(cmdf)) != EOF)
output[i++] = c;
- if (delim != '\0' && --i)
- output[i++] = delim;
- output[i++] = '\0';
pclose(cmdf);
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)
}
void getcmds(int time)
@@
-104,7
+111,8
@@
void getstatus(char *str)
{
strcpy(str + j, statusbar[i]);
}
{
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]))
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);
}
signal(SIGTERM, termhandler);
signal(SIGINT, termhandler);