[wiki] [sites] [dwm][patch] Cleaned up Ruleregex patch || MaliCopter

From: git=suckless.org via suckless wiki list <wiki_at_suckless.org>
Date: Sat, 10 Oct 2026 17:16:03 +0200

commit de4ea03cfa7677b358955a2b4bbf0c5e436eecca
Author: MaliCopter <mali.copter_at_gmx.de>
Date: Sat Oct 10 17:15:47 2026 +0200

    [dwm][patch] Cleaned up Ruleregex patch

diff --git a/dwm.suckless.org/patches/ruleregex/dwm-ruleregex-20261010-bf78dff.diff b/dwm.suckless.org/patches/ruleregex/dwm-ruleregex-20261010-bf78dff.diff
new file mode 100644
index 00000000..2f48eee6
--- /dev/null
+++ b/dwm.suckless.org/patches/ruleregex/dwm-ruleregex-20261010-bf78dff.diff
_at_@ -0,0 +1,51 @@
+From bf78dff9137dd705bfd15319a2ce0318fc122852 Mon Sep 17 00:00:00 2001
+From: MaliCopter <mali.copter_at_gmx.de>
+Date: Sat, 10 Oct 2026 16:55:11 +0200
+Subject: [PATCH] Rewrote Ruleregex patch for cleaner code
+
+---
+ dwm.c | 21 ++++++++++++++++++---
+ 1 file changed, 18 insertions(+), 3 deletions(-)
+
+diff --git a/dwm.c b/dwm.c
+index ab3a84c..3ac731c 100644
+--- a/dwm.c
++++ b/dwm.c
+_at_@ -274,6 +274,21 @@ static Window root, wmcheckwin;
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
+ /* function implementations */
++int
++applyregex(const char *name, const char *pattern)
++{
++ regex_t re;
++ int result;
++
++ if (regcomp(&re, pattern, REG_EXTENDED) != 0) goto fail;
++ result = regexec(&re, name, 0, NULL, 0);
++ regfree(&re);
++ if (result == 0) return 1;
++
++ fail:
++ return strstr(name, pattern) != NULL;
++}
++
+ void
+ applyrules(Client *c)
+ {
+_at_@ -292,9 +307,9 @@ applyrules(Client *c)
+
+ for (i = 0; i < LENGTH(rules); i++) {
+ r = &rules[i];
+- if ((!r->title || strstr(c->name, r->title))
+- && (!r->class || strstr(class, r->class))
+- && (!r->instance || strstr(instance, r->instance)))
++ if ((!r->title || applyregex(c->name, r->title))
++ && (!r->class || applyregex(class, r->class))
++ && (!r->instance || applyregex(instance, r->instance)))
+ {
+ c->isfloating = r->isfloating;
+ c->tags |= r->tags;
+--
+2.55.0
+
diff --git a/dwm.suckless.org/patches/ruleregex/index.md b/dwm.suckless.org/patches/ruleregex/index.md
index 55688a8b..28164950 100644
--- a/dwm.suckless.org/patches/ruleregex/index.md
+++ b/dwm.suckless.org/patches/ruleregex/index.md
_at_@ -8,7 +8,8 @@ instead of simple string matching.
 
 Download
 --------
-* [dwm-ruleregex-20260508-44a91a2.diff](dwm-ruleregex-20260508-44a91a2.diff)
+* [dwm-ruleregex-20261010-bf78dff.diff](dwm-ruleregex-20261010-bf78dff.diff) (2026-10-10) *latest*
+* [dwm-ruleregex-20260508-44a91a2.diff](dwm-ruleregex-20260508-44a91a2.diff) (2026-05-08) *deprecated*
 
 Authors
 -------
Received on Sat Oct 10 2026 - 17:16:03 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 10 2026 - 17:24:53 CEST