summaryrefslogtreecommitdiffstats
path: root/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/dwl.c b/dwl.c
index 44796b9..6d4ba98 100644
--- a/dwl.c
+++ b/dwl.c
@@ -11,6 +11,7 @@
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
+#include <regex.h>
#include <wayland-server-core.h>
#include <wlr/backend.h>
#include <wlr/backend/libinput.h>
@@ -402,6 +403,7 @@ static Monitor *xytomon(double x, double y);
static void xytonode(double x, double y, struct wlr_surface **psurface,
Client **pc, LayerSurface **pl, double *nx, double *ny);
static void zoom(const Arg *arg);
+static int regex_match(const char *pattern, const char *str);
/* variables */
static pid_t child_pid = -1;
@@ -551,8 +553,8 @@ applyrules(Client *c)
title = client_get_title(c);
for (r = rules; r < END(rules); r++) {
- if ((!r->title || strstr(title, r->title))
- && (!r->id || strstr(appid, r->id))) {
+ if ((!r->title || regex_match(r->title, title))
+ && (!r->id || regex_match(r->id, appid))) {
c->isfloating = r->isfloating;
newtags |= r->tags;
i = 0;
@@ -3519,6 +3521,19 @@ zoom(const Arg *arg)
arrange(selmon);
}
+int
+regex_match(const char *pattern, const char *str) {
+ regex_t regex;
+ int reti;
+ if (regcomp(&regex, pattern, REG_EXTENDED) != 0)
+ return 0;
+ reti = regexec(&regex, str, (size_t)0, NULL, 0);
+ regfree(&regex);
+ if (reti == 0)
+ return 1;
+ return 0;
+}
+
#ifdef XWAYLAND
void
activatex11(struct wl_listener *listener, void *data)