Hi pancake,
    Thanks for reviewing the patch. :)
    I understand your concern about not having to change dwm.c. I had
initially thought about a way to do it using the conventional stdin
statusbar. But, is seemed a little roundabout to take a string in the same
process out of it and then bring it back in using stdin... but I guess
that's just my feeling. There are also some other problems using a fifo.
- the fifo needs to be unique for every concurrently running dwm session. I
however have only one screen... so not exactly my problem :)
- writing to a fifo would block dwm in the printf. Worst yet, a little
mis-scriping at the statusbar end can cause a hung dwm.
- it will be hard for multiple extensions/patches to send data to the same
fifo. I guess some bash scripting and grepping at the stdin-statusbar end
could to away this problem at the cost of a slight inconvenience.
    That's why I wanted to solicit some feedback regarding a status text
configuration thing in dwm.c/config.h which could be used by other
extensions.

    I really like your idea about tagging the rest of the windows (after a
clientspertag operation) a separate tag. It goes well with dwm's tagging
paradigm too. Since the presence of a window with a tag is shown by dwm in
the left statusbar, it gets rid of my whether-or-not-cpt-is-active dilemma
too. However, activating cpt when seeing one tag and deactivating it when
seeing another can cause all the windows in the 'rest of clients' tag to be
tagged with the new tag. Also, if we are currently viewing a set of tags
then it is not easy to say what tags to assign to the 'rest of clients' when
deactivating cpt. Life doesn't seem to be all rosy with the tagging paradigm
here ;).

     About the enhanced monocle layout replacement, I can actually do the
following without problems:
     (Lets say I have two windows on a tag).
     Activate cpt=1. [Now the window in the master tag is full screen, The
number of hidden windows is shown in the status bar].
     Ctrl - j shifts focus to the hidden window. Visually, the red border
from the full screen is removed.
     Ctrl - <enter> zooms on the newly focussed window.

This still doesn't completely achieve the 'scolling through all windows'
effect. Probably the easiest alternative (as you suggested) is to zoom() on
the focussed client automatically on focusnext() if cpt = 1... and that
would be a cool improvement to clientspertag. One way is to have a
cptfocusnext doing the cpt related chores and calling the actual focusnext
appropriately. config.h handles binding Ctrl - j to cptfocusnext so that's
not a problem either. This solves the problem for clientspertag but ofcourse
is not general enough for a number of hooks (How about a config.c? That
could actually handle a lot of other problems too.).

Regards,
_r

P.S. thanks for putting the patch on the wiki.

On 10/27/07, pancake <[EMAIL PROTECTED]> wrote:
> Hi Ritesh!
>
> Welcome to the mailing list.
>
> Thanks for the patch, but I would like to discuss it before merging
> it to my patch because I don't want to make cpt modify dwm.c.
>
> I think stdout of dwm is probably a missunderstood friend.
> We can change all this patch by just adding a printf("%d/%d,cpt,n)
> and piping the stdout of dwm to a fifo reading it from stdin
> to show this value in the statusbar.
>
> cpt is very useful for me. I use it so many times and I understand
> that it can be replaced by making visible/hidden another tag with
> the 'rest of clients'. for example
>
>   * have two clients on tag 1 and one in tag 2
>   * press control+meta+2 twice
>
> This take more sense with the tagging concept and imho, this is the
> reason why cpt is not in dwm core.
>
> But I feel more confortable with cpt (mostly because I lets me decide
> how many clients I want to see instead of keeping sense contents on
> each tag and remember what tag contains.
>
> The other reason I find cpt useful is for using it as a enhaced
> monocle layout replacement. If we found a way to always show the
> focused window at the first position of the list we can have
> a 'scrolleable' view of a tag reducing the view to N clients per
> tag, but making the focused client always visible.
>
> I tried to do this patch but I was unable to find a proper way
> without using zoom(NULL) or without modifying dwm.c, coz there's
> no way to hook a callback to focusnext() and focusprev().
>
> What do you think about this concept?
>
>
>
> On Fri, 26 Oct 2007 05:32:32 -0400
> "Ritesh Kumar" <[EMAIL PROTECTED]> wrote:
>
> > Okay,  I revisited the patch and made some improvements.
> >  - variable names should be saner.
> >  - the status bar now shows the number of windows hidden instead of
> > the actual cpt value.
> >
> > _r
> >
> > diff -r 32c4d4563805 config.h
> > --- a/config.h  Thu Oct 25 19:24:28 2007 -0400
> > +++ b/config.h  Fri Oct 26 05:08:55 2007 -0400
> > @@ -37,6 +37,9 @@ Layout layouts[] = {
> >         { "[]=",                tile },
> >         { "><>",                floating },
> >  };
> > +
> > +/* Status text */
> > +char* statusbar[] = { cptstext, inputtext };
> >
> >  /* key definitions */
> >  #define MODKEY                 Mod1Mask
> > diff -r 32c4d4563805 dwm.c
> > --- a/dwm.c     Thu Oct 25 19:24:28 2007 -0400
> > +++ b/dwm.c     Fri Oct 26 05:22:22 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 setstext(void);
> >  void setup(void);
> >  void spawn(const char *arg);
> >  void tag(const char *arg);
> > @@ -192,7 +193,8 @@ void zoom(const char *arg);
> >  void zoom(const char *arg);
> >
> >  /* variables */
> > -char stext[256];
> > +char inputtext[256];
> > +char stext[512];
> >  double mwfact;
> >  int screen, sx, sy, sw, sh, wax, way, waw, wah;
> >  int (*xerrorxlib)(Display *, XErrorEvent *);
> > @@ -551,6 +553,7 @@ drawbar(void) {
> >         dc.w = blw;
> >         drawtext(layouts[ltidx].symbol, dc.norm);
> >         x = dc.x + dc.w;
> > +       setstext();
> >         dc.w = textw(stext);
> >         dc.x = sw - dc.w;
> >         if(dc.x < x) {
> > @@ -1312,21 +1315,21 @@ run(void) {
> >                         eprint("select failed\n");
> >                 }
> >                 if(FD_ISSET(STDIN_FILENO, &rd)) {
> > -                       switch(r = read(STDIN_FILENO, stext, sizeof
> > stext - 1)) {
> > +                       switch(r = read(STDIN_FILENO, inputtext,
> > sizeof inputtext - 1)) {
> >                         case -1:
> > -                               strncpy(stext, strerror(errno), sizeof
> > stext - 1);
> > -                               stext[sizeof stext - 1] = '\0';
> > +                               strncpy(inputtext, strerror(errno),
> > sizeof inputtext - 1);
> > +                               inputtext[sizeof inputtext - 1] = '\0';
> >                                 readin = False;
> >                                 break;
> >                         case 0:
> > -                               strncpy(stext, "EOF", 4);
> > +                               strncpy(inputtext, "EOF", 4);
> >                                 readin = False;
> >                                 break;
> >                         default:
> > -                               for(stext[r] = '\0', p = stext +
> > strlen(stext) - 1; p >= stext && *p == '\n'; *
> > -                               for(; p >= stext && *p != '\n'; --p);
> > -                               if(p > stext)
> > -                                       strncpy(stext, p + 1, sizeof
stext);
> > +                               for(inputtext[r] = '\0', p = inputtext
> > + strlen(inputtext) - 1; p >= inputtext
> > +                               for(; p >= inputtext && *p != '\n';
--p);
> > +                               if(p > inputtext)
> > +                                       strncpy(inputtext, p + 1,
> > sizeof inputtext);
> >                         }
> >                         drawbar();
> >                 }
> > @@ -1418,6 +1421,14 @@ setmwfact(const char *arg) {
> >  }
> >
> >  void
> > +setstext(void) {
> > +       int i;
> > +       stext[0] = '\0';
> > +       for(i=0; i<sizeof(statusbar)/sizeof(char*); i++)
> > +               strncat(stext, statusbar[i], sizeof(stext) -
strlen(stext));
> > +}
> > +
> > +void
> >  setup(void) {
> >         int d;
> >         unsigned int i, j, mask;
> > @@ -1498,7 +1509,7 @@ setup(void) {
> >         XDefineCursor(dpy, barwin, cursor[CurNormal]);
> >         updatebarpos();
> >         XMapRaised(dpy, barwin);
> > -       strcpy(stext, "dwm-"VERSION);
> > +       strcpy(inputtext, "dwm-"VERSION);
> >         dc.drawable = XCreatePixmap(dpy, root, sw, bh,
> > DefaultDepth(dpy, screen));
> >         dc.gc = XCreateGC(dpy, root, 0, 0);
> >         XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt,
JoinMiter);
> > diff -r 32c4d4563805 nmaster.c
> > --- a/nmaster.c Thu Oct 25 19:24:28 2007 -0400
> > +++ b/nmaster.c Fri Oct 26 05:20:54 2007 -0400
> > @@ -69,6 +69,8 @@ Layout layouts[] = {
> >  #endif
> >
> >  int cpt = -1;
> > +char cptstext[8];
> > +
> >  void clientspertag(const char *arg) {
> >          if (arg[0]=='^') {
> >                  if (cpt==-1) cpt = atoi(arg+1);
> > @@ -77,6 +79,18 @@ void clientspertag(const char *arg) {
> >          arrange();
> >  }
> >
> > +int getclientspertag(int n)
> > +{
> > +       if(cpt!=-1 && n>cpt){
> > +               snprintf(cptstext, 8, "{%d} ", n-cpt);
> > +               return cpt;
> > +       }
> > +
> > +       cptstext[0] = '\0';
> > +       drawbar();
> > +       return n;
> > +}
> > +
> >  #ifdef NMASTER
> >  int nmaster = NMASTER;
> >  void
> > @@ -87,7 +101,7 @@ ntile(void) {
> >         for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
> >                 n++;
> >
> > -       if (cpt!=-1 && n>cpt) n = cpt;
> > +       n = getclientspertag(n);
> >
> >         /* window geoms */
> >         mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster;
> > @@ -136,7 +150,7 @@ dntile(void) {
> >
> >         for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
> >                 n++;
> > -       if (cpt!=-1 && n>cpt) n = cpt;
> > +       n = getclientspertag(n);
> >
> >         /* dynamic nmaster */
> >         if (n<5) inc = 0;
> > @@ -266,7 +280,7 @@ tilecols(void) {
> >         else
> >                 rows = nrows;
> >
> > -       if (cpt!=-1 && n>cpt) n = cpt;
> > +       n = getclientspertag(n);
> >
> >         /* window geoms */
> >         mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster;
> >
> >
> > On 10/25/07, Ritesh Kumar <[EMAIL PROTECTED]> wrote:
> > > 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();
> > >  }
> > >
> >
>
>
>   --pancake
>
>

Reply via email to