removing newlines
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,4 +1,4 @@
|
||||
PREFIX ?= /usr/local
|
||||
PREFIX ?= ${HOME}/.local
|
||||
CC ?= cc
|
||||
LDFLAGS = -lX11
|
||||
|
||||
|
||||
15
dwmblocks.c
15
dwmblocks.c
@@ -34,6 +34,7 @@ void getsigcmds(unsigned int signal);
|
||||
void setupsignals();
|
||||
void sighandler(int signum);
|
||||
int getstatus(char *str, char *last);
|
||||
void remove_all(char *str, char to_remove);
|
||||
void statusloop();
|
||||
void termhandler();
|
||||
void pstdout();
|
||||
@@ -57,6 +58,19 @@ static char button[] = "\0";
|
||||
static int statusContinue = 1;
|
||||
static int returnStatus = 0;
|
||||
|
||||
void remove_all(char *str, char to_remove){
|
||||
char *read = str;
|
||||
char *write = str;
|
||||
while(*read) {
|
||||
if (*read == to_remove) {
|
||||
read++;
|
||||
*write = *read;
|
||||
}
|
||||
read++;
|
||||
write++;
|
||||
}
|
||||
}
|
||||
|
||||
//opens process *cmd and stores output in *output
|
||||
void getcmd(const Block *block, char *output)
|
||||
{
|
||||
@@ -83,6 +97,7 @@ void getcmd(const Block *block, char *output)
|
||||
return;
|
||||
int i = strlen(block->icon);
|
||||
fgets(output+i, CMDLENGTH-i-delimLen, cmdf);
|
||||
remove_all(output, '\n');
|
||||
i = strlen(output);
|
||||
if (i == 0) {
|
||||
//return if block and command output are both empty
|
||||
|
||||
Reference in New Issue
Block a user