[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: Thu, 19 Dec 2019 13:46:41 +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 Thu Dec 19 2019 - 13:46:41 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 22 2019 - 05:00:22 CET