Since the default rule matching does substring comparisons, using the
fixed string "broken" as a fallback value can complicate or make
unambiguous matching impossible, so this change makes various fallback
strings for unset properties configurable via config.h.
---
 config.def.h | 5 +++++
 dwm.c        | 7 +++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git config.def.h config.def.h
index a9ac303..8dfc8b1 100644
--- config.def.h
+++ config.def.h
@@ -43,6 +43,11 @@ static const Layout layouts[] = {
 	{ "[M]",      monocle },
 };
 
+/* Fallback strings for unset window properties. */
+static const char unset_instance_fallback[] = "broken";
+static const char unset_class_fallback[] = "broken";
+static const char unset_name_fallback[] = "broken";
+
 /* key definitions */
 #define MODKEY Mod1Mask
 #define TAGKEYS(KEY,TAG) \
diff --git dwm.c dwm.c
index c98678d..9735e32 100644
--- dwm.c
+++ dwm.c
@@ -235,7 +235,6 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
 static void zoom(const Arg *arg);
 
 /* variables */
-static const char broken[] = "broken";
 static char stext[256];
 static int screen;
 static int sw, sh;           /* X display screen geometry width, height */
@@ -288,8 +287,8 @@ applyrules(Client *c)
 	c->isfloating = 0;
 	c->tags = 0;
 	XGetClassHint(dpy, c->win, &ch);
-	class    = ch.res_class ? ch.res_class : broken;
-	instance = ch.res_name  ? ch.res_name  : broken;
+	class    = ch.res_class ? ch.res_class : unset_class_fallback;
+	instance = ch.res_name  ? ch.res_name  : unset_instance_fallback;
 
 	for (i = 0; i < LENGTH(rules); i++) {
 		r = &rules[i];
@@ -1998,7 +1997,7 @@ updatetitle(Client *c)
 	if (!gettextprop(c->win, netatom[NetWMName], c->name, sizeof c->name))
 		gettextprop(c->win, XA_WM_NAME, c->name, sizeof c->name);
 	if (c->name[0] == '\0') /* hack to mark broken clients */
-		strcpy(c->name, broken);
+		strcpy(c->name, unset_name_fallback);
 }
 
 void

Reply via email to