summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.def.h4
-rw-r--r--dwm.c24
2 files changed, 25 insertions, 3 deletions
diff --git a/config.def.h b/config.def.h
index c5e8fd5..e92de44 100644
--- a/config.def.h
+++ b/config.def.h
@@ -27,6 +27,10 @@ static const unsigned int alphas[][3] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" };
+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 --git a/dwm.c b/dwm.c
index 38ffb86..8b925a6 100644
--- a/dwm.c
+++ b/dwm.c
@@ -20,6 +20,7 @@
*
* To understand everything else, start reading main().
*/
+#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
#include <errno.h>
#include <locale.h>
#include <signal.h>
@@ -312,6 +313,7 @@ struct Pertag {
};
static unsigned int scratchtag = 1 << LENGTH(tags);
+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]; };
@@ -545,7 +547,7 @@ buttonpress(XEvent *e)
/* do not reserve space for vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
- x += TEXTW(tags[i]);
+ x += tagw[i];
} while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
@@ -829,6 +831,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)];
w = blw = TEXTW(m->ltsymbol);
/* clear bar from last draw */
@@ -845,10 +849,19 @@ drawbar(Monitor *m)
drw_text(drw, m->ww - w, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
}
+ for (i = 0; i < LENGTH(tags); i++)
+ masterclientontag[i] = NULL;
+
for (c = m->clients; c; c = c->next) {
occ |= c->tags == 255 ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
+ for (i = 0; i < LENGTH(tags); i++)
+ if (!masterclientontag[i] && c->tags & (1<<i)) {
+ masterclientontag[i] = c->name;
+ if (lcaselbl)
+ masterclientontag[i][0] = tolower(masterclientontag[i][0]);
+ }
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
@@ -856,9 +869,14 @@ drawbar(Monitor *m)
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
- 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);
x += w;
}
drw_setscheme(drw, scheme[SchemeNorm]);