]> git.armaanb.net Git - dwmblocks.git/blobdiff - dwmblocks.c
Fixes #9 - determine the size of the status buffer based on the number of blocks
[dwmblocks.git] / dwmblocks.c
index 88bdfb0b08f23616f70b6e2b08c643824eeea3a3..3af799f751cedaf21970f46ac2456bcb05f0e484 100644 (file)
@@ -6,6 +6,7 @@
 #include<X11/Xlib.h>
 #define LENGTH(X)               (sizeof(X) / sizeof (X[0]))
 #define CMDLENGTH              50
+#define STATUSLENGTH (LENGTH(blocks) * CMDLENGTH + 1)
 
 typedef struct {
        char* icon;
@@ -14,7 +15,6 @@ typedef struct {
        unsigned int signal;
 } Block;
 void sighandler(int num);
-void replace(char *str, char old, char new);
 void getcmds(int time);
 #ifndef __OpenBSD__
 void getsigcmds(int signal);
@@ -33,18 +33,10 @@ static Display *dpy;
 static int screen;
 static Window root;
 static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
-static char statusstr[2][256];
+static char statusstr[2][STATUSLENGTH];
 static int statusContinue = 1;
 static void (*writestatus) () = setroot;
 
-void replace(char *str, char old, char new)
-{
-       int N = strlen(str);
-       for(int i = 0; i < N; i++)
-               if(str[i] == old)
-                       str[i] = new;
-}
-
 //opens process *cmd and stores output in *output
 void getcmd(const Block *block, char *output)
 {