Hi,
    I am new to the list, so hi again :)
    I developed a small patch for dwm with pancake's clientspertag to
show if clientspertag is active. This basically adds additional status
text of the form '{n}' to the current status text where n is the
number of clientspertag currently active.
    However, I think a flexible way to show status messages could be
used by additional patches to show some textual data on the dwm status
bar. clientspertag seemed like a good candidate but I don't know about
any others. I was curious to know what you guys think.
     And thanks for developing dwm... its truly wonderful :)

_r


diff -r 32c4d4563805 config.h
--- a/config.h  Thu Oct 25 19:24:28 2007 -0400
+++ b/config.h  Thu Oct 25 20:28:00 2007 -0400
@@ -37,6 +37,9 @@ Layout layouts[] = {
        { "[]=",                tile },
        { "><>",                floating },
 };
+
+/* Status text */
+char* status_text[] = { cpt_stext, stext };

 /* key definitions */
 #define MODKEY                 Mod1Mask
diff -r 32c4d4563805 dwm.c
--- a/dwm.c     Thu Oct 25 19:24:28 2007 -0400
+++ b/dwm.c     Thu Oct 25 22:36:55 2007 -0400
@@ -167,6 +167,7 @@ void setclientstate(Client *c, long stat
 void setclientstate(Client *c, long state);
 void setlayout(const char *arg);
 void setmwfact(const char *arg);
+void setitext(void);
 void setup(void);
 void spawn(const char *arg);
 void tag(const char *arg);
@@ -193,6 +194,7 @@ void zoom(const char *arg);

 /* variables */
 char stext[256];
+char itext[512];
 double mwfact;
 int screen, sx, sy, sw, sh, wax, way, waw, wah;
 int (*xerrorxlib)(Display *, XErrorEvent *);
@@ -551,13 +553,14 @@ drawbar(void) {
        dc.w = blw;
        drawtext(layouts[ltidx].symbol, dc.norm);
        x = dc.x + dc.w;
-       dc.w = textw(stext);
+       setitext();
+       dc.w = textw(itext);
        dc.x = sw - dc.w;
        if(dc.x < x) {
                dc.x = x;
                dc.w = sw - x;
        }
-       drawtext(stext, dc.norm);
+       drawtext(itext, dc.norm);
        if((dc.w = dc.x - x) > bh) {
                dc.x = x;
                if(sel) {
@@ -1418,6 +1421,14 @@ setmwfact(const char *arg) {
 }

 void
+setitext(void) {
+       int i;
+       itext[0] = '\0';
+       for(i=0; i<sizeof(status_text)/sizeof(char*); i++)
+               strncat(itext, status_text[i], sizeof(itext) - strlen(itext));
+}
+
+void
 setup(void) {
        int d;
        unsigned int i, j, mask;
diff -r 32c4d4563805 nmaster.c
--- a/nmaster.c Thu Oct 25 19:24:28 2007 -0400
+++ b/nmaster.c Thu Oct 25 22:33:05 2007 -0400
@@ -69,11 +69,18 @@ Layout layouts[] = {
 #endif

 int cpt = -1;
+char cpt_stext[8];
+
 void clientspertag(const char *arg) {
         if (arg[0]=='^') {
                 if (cpt==-1) cpt = atoi(arg+1);
                 else cpt = -1;
         } else cpt = atoi(arg);
+               if(cpt == -1)
+                       cpt_stext[0] = '\0';
+               else
+                       snprintf(cpt_stext, 8, "{%d} ", cpt);
+               drawbar();
         arrange();
 }

Reply via email to