diff --git a/Makefile b/Makefile index ef43ef4..b8e245c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PREFIX ?= /usr/local +PREFIX ?= ${HOME}/.local CC ?= cc LDFLAGS = -lX11 diff --git a/dwmblocks.c b/dwmblocks.c index 8ed7575..27219c5 100644 --- a/dwmblocks.c +++ b/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