diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-16 12:29:03 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-16 12:29:03 +0200 |
commit | b2c6ee2efe63c608918727206b46484699dfde6e (patch) | |
tree | 121b718aabc13d5816b77041c312d1794f5acbe1 | |
parent | tmp (diff) | |
download | dwmblocks-b2c6ee2efe63c608918727206b46484699dfde6e.tar.gz dwmblocks-b2c6ee2efe63c608918727206b46484699dfde6e.tar.bz2 dwmblocks-b2c6ee2efe63c608918727206b46484699dfde6e.tar.xz dwmblocks-b2c6ee2efe63c608918727206b46484699dfde6e.tar.zst dwmblocks-b2c6ee2efe63c608918727206b46484699dfde6e.zip |
update
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | config.h | 13 | ||||
-rw-r--r-- | dwmblocks.c | 40 |
3 files changed, 32 insertions, 25 deletions
@@ -4,9 +4,9 @@ PREFIX = /usr/local CC = gcc dwmblocks: dwmblocks.o - $(CC) dwmblocks.o -lX11 -o dwmblocks + $(CC) -march=tigerlake -O3 -pipe dwmblocks.o -lX11 -o dwmblocks dwmblocks.o: dwmblocks.c config.h - $(CC) -c dwmblocks.c + $(CC) -march=tigerlake -O3 -pipe -c dwmblocks.c clean: rm -f *.o *.gch dwmblocks install: dwmblocks @@ -1,11 +1,12 @@ //Modify this file to change what commands output to your statusbar, and recompile using the make command. static const Block blocks[] = { - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ + /*Icon Command Update interval Update signal*/ + { "", "sb-mailbox", 180, 12 }, + { "", "sb-mpd", 5, 11 }, + { "", "sb-clock", 1, 1 }, + /* { "", "sb-music", 0, 11 }, */ /* {"⌨", "sb-kbselect", 0, 30}, */ /* {"", "cat /tmp/recordingicon 2>/dev/null", 0, 9}, */ - {"", "sb-tasks", 10, 26}, - {"", "sb-music", 0, 11}, - { " ", "sb-clock", 60, 1 }, /* {"", "sb-pacpackages", 0, 8}, */ /* {"", "sb-news", 0, 6}, */ /* {"", "sb-price lbc \"LBRY Token\" 📚", 9000, 22}, */ @@ -19,7 +20,6 @@ static const Block blocks[] = { /* {"", "sb-cpu", 10, 18}, */ /* {"", "sb-moonphase", 18000, 17}, */ /* {"", "sb-forecast", 18000, 5}, */ - /* {"", "sb-mailbox", 180, 12}, */ /* {"", "sb-nettraf", 1, 16}, */ /* {"", "sb-volume", 0, 10}, */ /* {"", "sb-battery", 5, 3}, */ @@ -28,7 +28,8 @@ static const Block blocks[] = { }; //Sets delimiter between status commands. NULL character ('\0') means no delimiter. -static char *delim = " | "; +static char *predelim = "["; +static char *postdelim = "]"; // 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 0186eff..773e36f 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -20,7 +20,7 @@ void buttonhandler(int sig, siginfo_t *si, void *ucontext); void replace(char *str, char old, char new); void remove_all(char *str, char to_remove); void getcmds(int time); -#ifndef __OpenBSD__ +#ifndef BSD void getsigcmds(int signal); void setupsignals(); void sighandler(int signum); @@ -78,11 +78,11 @@ int gcd(int a, int b) //opens process *cmd and stores output in *output void getcmd(const Block *block, char *output) { - if (block->signal) - { - output[0] = block->signal; - output++; - } + /* if (block->signal) */ + /* { */ + /* output[0] = block->signal; */ + /* output++; */ + /* } */ char *cmd = block->command; FILE *cmdf = popen(cmd,"r"); if (!cmdf){ @@ -100,19 +100,25 @@ void getcmd(const Block *block, char *output) int e; do { errno = 0; - s = fgets(tmpstr, CMDLENGTH-(strlen(delim)+1), cmdf); + s = fgets(tmpstr, CMDLENGTH-(strlen(postdelim)+1), cmdf); e = errno; } while (!s && e == EINTR); pclose(cmdf); - int i = strlen(block->icon); - strcpy(output, block->icon); - strcpy(output+i, tmpstr); + if (s == NULL) { + output[0] = '\0'; + return; + } + int i = strlen(predelim); + strlcpy(output, predelim, CMDLENGTH); + strlcpy(output + i, block->icon, CMDLENGTH); + i += strlen(block->icon); + strlcpy(output + i, tmpstr, CMDLENGTH); remove_all(output, '\n'); i = strlen(output); - if ((i > 0 && block != &blocks[LENGTH(blocks) - 1])){ - strcat(output, delim); + if (i > 0){ + strcat(output, postdelim); } - i+=strlen(delim); + i += strlen(postdelim); output[i++] = '\0'; } @@ -128,7 +134,7 @@ void getcmds(int time) } } -#ifndef __OpenBSD__ +#ifndef BSD void getsigcmds(int signal) { const Block *current; @@ -221,7 +227,7 @@ void pstdout() void statusloop() { -#ifndef __OpenBSD__ +#ifndef BSD setupsignals(); #endif // first figure out the default wait interval by finding the @@ -255,7 +261,7 @@ void statusloop() } } -#ifndef __OpenBSD__ +#ifndef BSD void sighandler(int signum) { getsigcmds(signum-SIGRTMIN); @@ -299,7 +305,7 @@ int main(int argc, char** argv) for(int i = 0; i < argc; i++) { if (!strcmp("-d",argv[i])) - delim = argv[++i]; + postdelim = argv[++i]; else if(!strcmp("-p",argv[i])) writestatus = pstdout; } |