From d1519aa012e8aa2aee0a77b6137c32abb66e77a8 Mon Sep 17 00:00:00 2001 From: mackarelfish Date: Sat, 30 May 2020 12:21:26 +0700 Subject: [PATCH 1/4] Fixed weird blocks behaviour with moving text --- dwmblocks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwmblocks.c b/dwmblocks.c index bf648c2..92e9570 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -75,7 +75,7 @@ void getcmd(const Block *block, char *output) return; char c; int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-i, cmdf); + fgets(output+i, CMDLENGTH-2, cmdf); remove_all(output, '\n'); i = strlen(output); if (delim != '\0' && i) From 9adc4dc1e7a2230d24ef1dada9b888b16aec374c Mon Sep 17 00:00:00 2001 From: mackarelfish Date: Sat, 30 May 2020 12:36:18 +0700 Subject: [PATCH 2/4] Added support for multiple char delimiter --- config.h | 4 ++-- dwmblocks.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config.h b/config.h index 5c71ce5..31011ad 100644 --- a/config.h +++ b/config.h @@ -2,7 +2,7 @@ static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, - /* {"", "music", 0, 11}, */ + {"", "music", 0, 11}, {"", "pacpackages", 0, 8}, {"", "news", 0, 6}, /* {"", "crypto", 0, 13}, */ @@ -24,7 +24,7 @@ static const Block blocks[] = { }; //sets delimeter between status commands. NULL character ('\0') means no delimeter. -static char delim = ' '; +static char *delim = " "; // Have dwmblocks automatically recompile and run when you edit this file in // vim with the following line in your vimrc/init.vim: diff --git a/dwmblocks.c b/dwmblocks.c index 92e9570..391ee0d 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -75,11 +75,12 @@ void getcmd(const Block *block, char *output) return; char c; int i = strlen(block->icon); - fgets(output+i, CMDLENGTH-2, cmdf); + fgets(output+i, CMDLENGTH-(strlen(delim)+1), cmdf); remove_all(output, '\n'); i = strlen(output); - if (delim != '\0' && i) - output[i++] = delim; + if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])) + strcat(output, delim); + i+=strlen(delim); output[i++] = '\0'; pclose(cmdf); } @@ -130,8 +131,11 @@ int getstatus(char *str, char *last) { strcpy(last, str); str[0] = '\0'; - for(int i = 0; i < LENGTH(blocks); i++) + for(int i = 0; i < LENGTH(blocks); i++) { strcat(str, statusbar[i]); + if (i == LENGTH(blocks) - 1) + strcat(str, " "); + } str[strlen(str)-1] = '\0'; return strcmp(str, last);//0 if they are the same } @@ -218,7 +222,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]; else if(!strcmp("-p",argv[i])) writestatus = pstdout; } From e2ca6028d61859b66816fadeb6103fee1fa58314 Mon Sep 17 00:00:00 2001 From: Zaky Bilfagih <55378008+mackarelfish@users.noreply.github.com> Date: Sat, 30 May 2020 12:44:06 +0700 Subject: [PATCH 3/4] Commented out music from default config.h --- config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.h b/config.h index 31011ad..6106bba 100644 --- a/config.h +++ b/config.h @@ -2,7 +2,7 @@ static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, - {"", "music", 0, 11}, + /* {"", "music", 0, 11},*/ {"", "pacpackages", 0, 8}, {"", "news", 0, 6}, /* {"", "crypto", 0, 13}, */ From b259b140a32fa42a1950f33f1f135bacaf6603f1 Mon Sep 17 00:00:00 2001 From: Christian S Date: Sun, 31 May 2020 17:59:42 +0200 Subject: [PATCH 4/4] POSIX Makefile --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 659ae87..c2c3c6b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -PREFIX ?= /usr/local +.POSIX: + +PREFIX = /usr/local output: dwmblocks.o gcc dwmblocks.o -lX11 -o dwmblocks @@ -12,3 +14,5 @@ install: output chmod 755 $(DESTDIR)$(PREFIX)/bin/dwmblocks uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dwmblocks + +.PHONY: clean install uninstall