{"", "~/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 = "|";
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)
{
strcpy(str + j, statusbar[i]);
}
- str[--j] = '\0';
+ for (int i = 0; delim[i]; i++)
+ str[--j] = '\0';
}
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);