[hackers] [dwm][PATCH] Added the possibility to set an alternative text for tags relative to non-empty windows

From: Luigi Foscari <foscari.luigi_AT_gmail.com>
Date: Wed, 18 Dec 2019 00:29:08 +0100

From: Luigi Foscari <luigi.foscari_AT_icloud.com>

---
 config.def.h |  1 +
 dwm.c        | 10 ++++------
 2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..c56f61c 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -20,6 +20,7 @@ static const char *colors[][3]      = {
 
 /* tagging */
 static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const char *alttags[] = { "[1]", "[2]", "[3]", "[4]", "[5]", "[6]", "[7]", "[8]", "[9]" };
 
 static const Rule rules[] = {
 	/* xprop(1):
diff --git a/dwm.c b/dwm.c
index 4465af1..0b065ba 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -699,6 +699,7 @@ drawbar(Monitor *m)
 	int boxs = drw->fonts->h / 9;
 	int boxw = drw->fonts->h / 6 + 2;
 	unsigned int i, occ = 0, urg = 0;
+	const char *tagtext;
 	Client *c;
 
 	/* draw status first so it can be overdrawn by tags later */
_AT_@ -715,13 +716,10 @@ drawbar(Monitor *m)
 	}
 	x = 0;
 	for (i = 0; i < LENGTH(tags); i++) {
-		w = TEXTW(tags[i]);
+		tagtext = occ & 1 << i ? alttags[i] : tags[i];
+		w = TEXTW(tagtext);
 		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);
-		if (occ & 1 << i)
-			drw_rect(drw, x + boxs, boxs, boxw, boxw,
-				m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
-				urg & 1 << i);
+		drw_text(drw, x, 0, w, bh, lrpad / 2, tagtext, urg & 1 << i);
 		x += w;
 	}
 	w = blw = TEXTW(m->ltsymbol);
-- 
2.24.1
Received on Wed Dec 18 2019 - 00:29:08 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 18 2019 - 00:36:30 CET