add inverse-rules patch

This commit is contained in:
Zuki Air 2025-05-29 14:33:40 +01:00
parent 61d5f3c503
commit 58cc77febd
3 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,2 @@
### Description
Adds flag to invert a window rule and apply that rule to only non matching windows

View File

@ -0,0 +1,54 @@
From 1bfb993652e5d276565be6e5f2e85870d3a8f379 Mon Sep 17 00:00:00 2001
From: Zuki Air <zukirust@gmail.com>
Date: Thu, 29 May 2025 14:38:23 +0100
Subject: [PATCH] inverse-rules-0.7.patch
---
config.def.h | 6 +++---
dwl.c | 5 +++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..0aaa6a0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,10 +22,10 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating monitor inverse*/
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, false}, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, false}, /* Start on ONLY tag "9" */
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index a2711f6..5a5c8ec 100644
--- a/dwl.c
+++ b/dwl.c
@@ -231,6 +231,7 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ bool inverse;
} Rule;
typedef struct {
@@ -467,8 +468,8 @@ applyrules(Client *c)
title = broken;
for (r = rules; r < END(rules); r++) {
- if ((!r->title || strstr(title, r->title))
- && (!r->id || strstr(appid, r->id))) {
+ if (((!r->title || strstr(title, r->title))
+ && (!r->id || strstr(appid, r->id))) ^ r->inverse) {
c->isfloating = r->isfloating;
newtags |= r->tags;
i = 0;
--
2.49.0

View File

@ -0,0 +1,55 @@
From d1da5bfe4e94c0acbb9c8cb568a0a0c67a670a79 Mon Sep 17 00:00:00 2001
From: Zuki Air <zukirust@gmail.com>
Date: Thu, 29 May 2025 14:24:02 +0100
Subject: [PATCH] inverse rules patch
adds a rule flag to allow a user to apply a rule to all but one window.
---
config.def.h | 6 +++---
dwl.c | 5 +++--
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..0aaa6a0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,10 +22,10 @@ static int log_level = WLR_ERROR;
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
+ /* app_id title tags mask isfloating monitor inverse*/
/* examples: */
- { "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
- { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
+ { "Gimp_EXAMPLE", NULL, 0, 1, -1, false}, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 0, -1, false}, /* Start on ONLY tag "9" */
};
/* layout(s) */
diff --git a/dwl.c b/dwl.c
index 4816159..57d8a09 100644
--- a/dwl.c
+++ b/dwl.c
@@ -228,6 +228,7 @@ typedef struct {
uint32_t tags;
int isfloating;
int monitor;
+ bool inverse;
} Rule;
typedef struct {
@@ -488,8 +489,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 || strstr(title, r->title))
+ && (!r->id || strstr(appid, r->id))) ^ r->inverse) {
c->isfloating = r->isfloating;
newtags |= r->tags;
i = 0;
--
2.49.0