diff -pu dwm.git/config.def.h dwm.programtags/config.def.h --- dwm.git/config.def.h 2021-02-27 20:04:32.030570909 -0600 +++ dwm.programtags/config.def.h 2021-03-15 16:24:23.620864957 -0500 @@ -21,6 +21,10 @@ static const char *colors[][3] = { /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const char ptagf[] = "[%s %s]"; /* format of a tag label */ +static const char etagf[] = "[%s]"; /* format of an empty tag */ +static const int lcaselbl = 0; /* 1 means make tag label lowercase */ + static const Rule rules[] = { /* xprop(1): * WM_CLASS(STRING) = instance, class diff -pu dwm.git/dwm.c dwm.programtags/dwm.c --- dwm.git/dwm.c 2021-02-27 20:04:32.030570909 -0600 +++ dwm.programtags/dwm.c 2021-03-15 16:30:13.580457535 -0500 @@ -20,6 +20,7 @@ * * To understand everything else, start reading main(). */ +#include /* for making tab label lowercase, very tiny standard library */ #include #include #include @@ -272,6 +273,8 @@ static Window root, wmcheckwin; /* configuration, allows nested code to access above variables */ #include "config.h" +unsigned int tagw[LENGTH(tags)]; + /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -433,7 +436,7 @@ buttonpress(XEvent *e) if (ev->window == selmon->barwin) { i = x = 0; do - x += TEXTW(tags[i]); + x += tagw[i]; while (ev->x >= x && ++i < LENGTH(tags)); if (i < LENGTH(tags)) { click = ClkTagBar; @@ -701,6 +704,8 @@ drawbar(Monitor *m) int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; Client *c; + char taglabel[64]; + char *masterclientontag[LENGTH(tags)]; /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ @@ -709,16 +714,32 @@ drawbar(Monitor *m) drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); } + for (i = 0; i < LENGTH(tags); i++) + masterclientontag[i] = NULL; + for (c = m->clients; c; c = c->next) { occ |= c->tags; if (c->isurgent) urg |= c->tags; + for (i = 0; i < LENGTH(tags); i++) + if (!masterclientontag[i] && c->tags & (1<win, &ch); + masterclientontag[i] = ch.res_class; + if (lcaselbl) + masterclientontag[i][0] = tolower(masterclientontag[i][0]); + } } x = 0; for (i = 0; i < LENGTH(tags); i++) { - w = TEXTW(tags[i]); + if (masterclientontag[i]) + snprintf(taglabel, 64, ptagf, tags[i], masterclientontag[i]); + else + snprintf(taglabel, 64, etagf, tags[i]); + masterclientontag[i] = taglabel; + tagw[i] = w = TEXTW(masterclientontag[i]); drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); + drw_text(drw, x, 0, w, bh, lrpad / 2, masterclientontag[i], urg & 1 << i); if (occ & 1 << i) drw_rect(drw, x + boxs, boxs, boxw, boxw, m == selmon && selmon->sel && selmon->sel->tags & 1 << i,