URI: 
       dwm-nametag-prepend-6.2.diff - sites - public wiki contents of suckless.org
  HTML git clone git://git.suckless.org/sites
   DIR Log
   DIR Files
   DIR Refs
       ---
       dwm-nametag-prepend-6.2.diff (1608B)
       ---
            1 --- a/config.def.h
            2 +++ b/config.def.h
            3 @@ -19,7 +19,10 @@
            4  };
            5  
            6  /* tagging */
            7 -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
            8 +#define MAX_TAGNAME_LEN 14                /* excludes TAG_PREPEND */
            9 +#define TAG_PREPEND "%1i:"                /* formatted as 2 chars */
           10 +#define MAX_TAGLEN 16                        /* altogether */
           11 +static char tags[][MAX_TAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
           12  
           13  static const Rule rules[] = {
           14          /* xprop(1):
           15 --- a/dwm.c
           16 +++ b/dwm.c
           17 @@ -183,6 +183,7 @@
           18  static void monocle(Monitor *m);
           19  static void motionnotify(XEvent *e);
           20  static void movemouse(const Arg *arg);
           21 +static void nametag(const Arg *arg);
           22  static Client *nexttiled(Client *c);
           23  static void pop(Client *);
           24  static void propertynotify(XEvent *e);
           25 @@ -1190,6 +1191,34 @@
           26                  selmon = m;
           27                  focus(NULL);
           28          }
           29 +}
           30 +
           31 +void
           32 +nametag(const Arg *arg) {
           33 +        char *p, name[MAX_TAGNAME_LEN];
           34 +        FILE *f;
           35 +        int i;
           36 +
           37 +        errno = 0; // popen(3p) says on failure it "may" set errno
           38 +        if(!(f = popen("dmenu < /dev/null", "r"))) {
           39 +                fprintf(stderr, "dwm: popen 'dmenu < /dev/null' failed%s%s\n", errno ? ": " : "", errno ? strerror(errno) : "");
           40 +                return;
           41 +        }
           42 +        if (!(p = fgets(name, MAX_TAGNAME_LEN, f)) && (i = errno) && ferror(f))
           43 +                fprintf(stderr, "dwm: fgets failed: %s\n", strerror(i));
           44 +        if (pclose(f) < 0)
           45 +                fprintf(stderr, "dwm: pclose failed: %s\n", strerror(errno));
           46 +        if(!p)
           47 +                return;
           48 +        if((p = strchr(name, '\n')))
           49 +                *p = '\0';
           50 +
           51 +        for(i = 0; i < LENGTH(tags); i++)
           52 +                if(selmon->tagset[selmon->seltags] & (1 << i)) {
           53 +                        sprintf(tags[i], TAG_PREPEND, i+1);
           54 +                        strcat(tags[i], name);
           55 +                }
           56 +        drawbars();
           57  }
           58  
           59  Client *