aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--config.h13
-rw-r--r--dwmblocks.c40
3 files changed, 32 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 5cfbb5a..264d490 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/config.h b/config.h
index 493b3af..4fa03ac 100644
--- a/config.h
+++ b/config.h
@@ -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;
}