dwm-noxz

[fork] suckless dwm - personal fork
git clone https://noxz.tech/git/dwm-noxz.git
Log | Files | README | LICENSE

commit: f9a77840a324aaa65c8ebd1bddb9962a502e60d6
parent: ef7edf1ff83aa2d87e465ba7c04d71872e6a2422
author: Chris Noxz <chris@noxz.tech>
date:   Wed, 5 Feb 2020 12:18:11 +0100
Fix status length by excluding color scheme references
Mdwm.c14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dwm.c b/dwm.c
@@ -859,7 +859,19 @@ drawbar(Monitor *m)
 	/* draw status first so it can be overdrawn by tags later */
 	if (m == selmon) { /* status is only drawn on selected monitor */
 		drw_setscheme(drw, scheme[SchemeStatusNorm]);
-		sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+		/* get string width excluding color scheme references */
+		while (1) {
+			if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; }
+			ctmp = *ts;
+			*ts = '\0';
+			sw += TEXTW(tp) -lrpad;
+			if (ctmp == '\0') { break; }
+			*ts = ctmp;
+			tp = ++ts;
+		}
+		sw += 2; /* 2px right padding */
+		ts = stext;
+		tp = stext;
 		while (1) {
 			if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; }
 			ctmp = *ts;