-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathdwm-switchtag-6.5.diff
135 lines (126 loc) · 4.06 KB
/
dwm-switchtag-6.5.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From 1c298466a705ea6c35305ebcc15553b5eb147f75 Mon Sep 17 00:00:00 2001
From: Bakkeby <bakkeby@gmail.com>
Date: Wed, 26 Jun 2024 23:03:08 +0200
Subject: [PATCH] switchtag patch
Adding switchtag option for rules allowing auto-moving
dedicated tags for specific applications.
dwm allow you to set application specific rules so that you can have your browser, for example,
start up on tag 9 optionally on a given monitor.
When you open your browser it is then automatically moved to the configured tag, but you have
to manually enable the tag to see the newly opened application.
This patch adds an extra configuration option for individual rules where:
- 0 is default behaviour
- 1 automatically moves you to the tag of the newly opened application and
- 2 enables the tag of the newly opened application in addition to your existing enabled tags
- 3 as 1, but closing that window reverts the view back to what it was previously (*)
- 4 as 2, but closing that window reverts the view back to what it was previously (*)
(*) except if the client has been moved between tags or to another monitor
---
config.def.h | 6 +++---
dwm.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 9efa774..a92ca59 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,9 +26,9 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ /* class instance title tags mask switchtag isfloating monitor */
+ { "Gimp", NULL, NULL, 0, 1, 1, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 1, 0, -1 },
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index f1d86b2..172c45d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -92,6 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw;
unsigned int tags;
+ unsigned int switchtag;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
Client *next;
Client *snext;
@@ -137,6 +138,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ int switchtag;
int isfloating;
int monitor;
} Rule;
@@ -279,7 +281,7 @@ void
applyrules(Client *c)
{
const char *class, *instance;
- unsigned int i;
+ unsigned int i, newtagset;
const Rule *r;
Monitor *m;
XClassHint ch = { NULL, NULL };
@@ -302,6 +304,25 @@ applyrules(Client *c)
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
c->mon = m;
+
+ if (r->switchtag) {
+ selmon = c->mon;
+ if (r->switchtag == 2 || r->switchtag == 4)
+ newtagset = c->mon->tagset[c->mon->seltags] ^ c->tags;
+ else
+ newtagset = c->tags;
+
+ if (newtagset && !(c->tags & c->mon->tagset[c->mon->seltags])) {
+ if (r->switchtag == 3 || r->switchtag == 4)
+ c->switchtag = c->mon->tagset[c->mon->seltags];
+ if (r->switchtag == 1 || r->switchtag == 3)
+ view(&((Arg) { .ui = newtagset }));
+ else {
+ c->mon->tagset[c->mon->seltags] = newtagset;
+ arrange(c->mon);
+ }
+ }
+ }
}
}
if (ch.res_class)
@@ -1431,6 +1452,8 @@ sendmon(Client *c, Monitor *m)
attachstack(c);
focus(NULL);
arrange(NULL);
+ if (c->switchtag)
+ c->switchtag = 0;
}
void
@@ -1671,6 +1694,8 @@ tag(const Arg *arg)
{
if (selmon->sel && arg->ui & TAGMASK) {
selmon->sel->tags = arg->ui & TAGMASK;
+ if (selmon->sel->switchtag)
+ selmon->sel->switchtag = 0;
focus(NULL);
arrange(selmon);
}
@@ -1779,6 +1804,7 @@ void
unmanage(Client *c, int destroyed)
{
Monitor *m = c->mon;
+ unsigned int switchtag = c->switchtag;
XWindowChanges wc;
detach(c);
@@ -1799,6 +1825,8 @@ unmanage(Client *c, int destroyed)
focus(NULL);
updateclientlist();
arrange(m);
+ if (switchtag)
+ view(&((Arg) { .ui = switchtag }));
}
void
--
2.45.2