On Wed, Apr 09, 2008 at 07:17:06PM -0400, Jeremy O'Brien wrote:
> I recommend looking in applyrules() for some example code. You may be able 
> to adapt it in killclient() :)

I had thought of that before, but I was still using 4.7 with regex
matching and that looked complicated to me.
Anyway, it wasn't difficult, especially with 4.9.
Thanks for the hint!

The solution is not very elegant (See attachment), but it works for me.

Thanks for dwm, it is great software

Martin
diff -up dwm-4.9/config.def.h dwm-4.9-nokill/config.def.h
--- dwm-4.9/config.def.h	2008-04-03 22:57:01.000000000 +0200
+++ dwm-4.9-nokill/config.def.h	2008-04-11 06:14:07.000000000 +0200
@@ -14,8 +14,9 @@
 const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
 
 Rule rules[] = {
-	/* class	instance	title		tags ref	isfloating */
-	{ "Gimp",	NULL,		NULL,		NULL,		True },
+	/* class	instance	title		tags ref	isfloating iskillable*/
+	{ "Gimp",	NULL,		NULL,		NULL,		True , True},
+	{ "UXTerm",	NULL,		NULL,		NULL,		False, False },
 };
 
 /* geometries, s{x,y,w,h} and bh are already initualized here */
Nur in dwm-4.9-nokill: .config.h.swp.
diff -up dwm-4.9/dwm.c dwm-4.9-nokill/dwm.c
--- dwm-4.9/dwm.c	2008-04-03 22:57:01.000000000 +0200
+++ dwm-4.9-nokill/dwm.c	2008-04-11 05:37:02.000000000 +0200
@@ -117,6 +117,7 @@ typedef struct {
 	const char *title;
 	const char *tag;
 	Bool isfloating;
+	Bool iskillable;
 } Rule;
 
 /* function declarations */
@@ -161,6 +162,7 @@ Bool isurgent(unsigned int t);
 Bool isvisible(Client *c);
 void keypress(XEvent *e);
 void killclient(const char *arg);
+Bool killable(Client *c);
 void manage(Window w, XWindowAttributes *wa);
 void mappingnotify(XEvent *e);
 void maprequest(XEvent *e);
@@ -963,11 +965,34 @@ keypress(XEvent *e) {
 		}
 }
 
+Bool
+killable(Client *c) {
+	unsigned int i;
+	Rule *r;
+	XClassHint ch = { 0 };
+	Bool matched = True;
+
+	/* rule matching */
+	XGetClassHint(dpy, c->win, &ch);
+	for(i = 0; i < LENGTH(rules); i++) {
+		r = &rules[i];
+		if(!r->iskillable && ((r->title && strstr(c->name, r->title))
+		|| (ch.res_class && r->class && strstr(ch.res_class, r->class))
+		|| (ch.res_name && r->instance && strstr(ch.res_name, r->instance))))
+			matched=False;
+	}
+	if(ch.res_class)
+		XFree(ch.res_class);
+	if(ch.res_name)
+		XFree(ch.res_name);
+	return matched;
+}
+
 void
 killclient(const char *arg) {
 	XEvent ev;
 
-	if(!sel)
+	if(!sel || !killable(sel))
 		return;
 	if(isprotodel(sel)) {
 		ev.type = ClientMessage;

Reply via email to