[hackers] [dwm][PATCH] Add color scheme entry for urgent windows

From: Ian Remmler <ian_AT_remmler.org>
Date: Fri, 20 Sep 2019 22:27:18 -0500

Draw tags to which windows with the urgent hint set are attached with a
color scheme entry rather than inverting the normal colors.

Included is the patch that Ivan Tham recently posted to highlight the
window's border as well, modified to use the new scheme entry.

---
 config.def.h |  2 ++
 dwm.c        | 14 +++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..6bd28f8 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -12,10 +12,12 @@ static const char col_gray2[]       = "#444444";
 static const char col_gray3[]       = "#bbbbbb";
 static const char col_gray4[]       = "#eeeeee";
 static const char col_cyan[]        = "#005577";
+static const char col_red[]         = "#aa0000";
 static const char *colors[][3]      = {
 	/*               fg         bg         border   */
 	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
 	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
+	[SchemeUrg]  = { col_gray4, col_red,   col_red   },
 };
 
 /* tagging */
diff --git a/dwm.c b/dwm.c
index 4465af1..dc122a2 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -59,7 +59,7 @@
 
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
-enum { SchemeNorm, SchemeSel }; /* color schemes */
+enum { SchemeNorm, SchemeSel, SchemeUrg }; /* color schemes */
 enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
        NetWMFullscreen, NetActiveWindow, NetWMWindowType,
        NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
_AT_@ -716,12 +716,14 @@ drawbar(Monitor *m)
 	x = 0;
 	for (i = 0; i < LENGTH(tags); i++) {
 		w = TEXTW(tags[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);
+		if (m->tagset[m->seltags] & 1 << i)
+			drw_setscheme(drw, scheme[SchemeSel]);
+		else
+			drw_setscheme(drw, scheme[urg & 1 << i ? SchemeUrg : SchemeNorm]);
+		drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], 0);
 		if (occ & 1 << i)
 			drw_rect(drw, x + boxs, boxs, boxw, boxw,
-				m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
-				urg & 1 << i);
+				m == selmon && selmon->sel && selmon->sel->tags & 1 << i, 0);
 		x += w;
 	}
 	w = blw = TEXTW(m->ltsymbol);
_AT_@ -1233,6 +1235,8 @@ propertynotify(XEvent *e)
 		case XA_WM_HINTS:
 			updatewmhints(c);
 			drawbars();
+			if (c->isurgent)
+				XSetWindowBorder(dpy, c->win, scheme[SchemeUrg][ColBorder].pixel);
 			break;
 		}
 		if (ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
-- 
2.23.0
Received on Sat Sep 21 2019 - 05:27:18 CEST

This archive was generated by hypermail 2.3.0 : Sat Sep 21 2019 - 06:12:24 CEST