Files
dwl-patches/patches/switchtotag/switchtotag.patch
T
2026-10-20 21:28:18 +02:00

78 lines
2.4 KiB
Diff

From b636e766b42a75404ada4a5c39fd66221bb19b0b Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Sun, 4 Oct 2026 10:22:14 +0200
Subject: [PATCH] allow switching to the configured tag when a window opens
Add a rule option to switch to the configured tag when a window opens,
then switch back when it closes.
---
config.def.h | 6 +++---
dwl.c | 13 +++++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index a4019d3..ffb0d6a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -22,9 +22,9 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
static const Rule rules[] = {
- /* app_id title tags mask isfloating monitor */
- { "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" */
+ /* app_id title tags mask switchtotag isfloating monitor */
+ { "Gimp_EXAMPLE", NULL, 0, 0 1, -1 }, /* Start on currently visible tags floating, not tiled */
+ { "firefox_EXAMPLE", NULL, 1 << 8, 1 0, -1 }, /* Start on ONLY tag "9" */
/* default/example rule: can be changed but cannot be eliminated; at least one rule must exist */
};
diff --git a/dwl.c b/dwl.c
index 7d8fc1e..8201d29 100644
--- a/dwl.c
+++ b/dwl.c
@@ -162,6 +162,7 @@ typedef struct {
unsigned int bw;
uint32_t tags;
int isfloating, isurgent, isfullscreen;
+ int switchtotag;
} Client;
typedef struct {
@@ -250,6 +251,7 @@ typedef struct {
const char *id;
const char *title;
uint32_t tags;
+ bool switchtotag;
int isfloating;
int monitor;
} Rule;
@@ -594,6 +596,11 @@ applyrules(Client *c)
if (r->monitor == i++)
mon = m;
}
+ if (r->switchtotag && client_surface(c)->mapped) {
+ c->switchtotag = selmon->tagset[selmon->seltags];
+ mon->seltags ^= 1;
+ mon->tagset[selmon->seltags] = r->tags & TAGMASK;
+ }
}
}
@@ -3227,6 +3234,12 @@ unmapnotify(struct wl_listener *listener, void *data)
c->snapshot = NULL;
c->resize_serial = 0;
c->current = (struct wlr_box){0};
+
+ if (c->switchtotag) {
+ Arg a = { .ui = c->switchtotag };
+ view(&a);
+ }
+
printstatus();
motionnotify(0, NULL, 0, 0, 0, 0);
}
--
2.56.0