diff options
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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(®ex, pattern, REG_EXTENDED) != 0) + return 0; + reti = regexec(®ex, str, (size_t)0, NULL, 0); + regfree(®ex); + if (reti == 0) + return 1; + return 0; +} + #ifdef XWAYLAND void activatex11(struct wl_listener *listener, void *data) |