nixos-dotfiles

nixos-dotfiles

https://git.tonybtw.com/nixos-dotfiles.git git://git.tonybtw.com/nixos-dotfiles.git
12,316 bytes raw
1
From 8d29d5cace06c97917fbc26c673fd37731ac4984 Mon Sep 17 00:00:00 2001
2
From: Bonicgamer <44382222+Bonicgamer@users.noreply.github.com>
3
Date: Mon, 17 Aug 2020 14:48:24 -0400
4
Subject: [PATCH 1/2] Implement vanitygaps
5
MIME-Version: 1.0
6
Content-Type: text/plain; charset=UTF-8
7
Content-Transfer-Encoding: 8bit
8
9
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
10
---
11
 config.def.h |  21 ++++++++
12
 dwl.c        | 149 +++++++++++++++++++++++++++++++++++++++++++++++----
13
 2 files changed, 160 insertions(+), 10 deletions(-)
14
15
diff --git a/config.def.h b/config.def.h
16
index 22d2171d..39e528b1 100644
17
--- a/config.def.h
18
+++ b/config.def.h
19
@@ -6,7 +6,12 @@
20
 /* appearance */
21
 static const int sloppyfocus               = 1;  /* focus follows mouse */
22
 static const int bypass_surface_visibility = 0;  /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible  */
23
+static const int smartgaps                 = 0;  /* 1 means no outer gap when there is only one window */
24
 static const unsigned int borderpx         = 1;  /* border pixel of windows */
25
+static const unsigned int gappih           = 10; /* horiz inner gap between windows */
26
+static const unsigned int gappiv           = 10; /* vert inner gap between windows */
27
+static const unsigned int gappoh           = 10; /* horiz outer gap between windows and screen edge */
28
+static const unsigned int gappov           = 10; /* vert outer gap between windows and screen edge */
29
 static const float rootcolor[]             = COLOR(0x222222ff);
30
 static const float bordercolor[]           = COLOR(0x444444ff);
31
 static const float focuscolor[]            = COLOR(0x005577ff);
32
@@ -133,6 +138,22 @@ static const Key keys[] = {
33
 	{ MODKEY,                    XKB_KEY_d,          incnmaster,     {.i = -1} },
34
 	{ MODKEY,                    XKB_KEY_h,          setmfact,       {.f = -0.05f} },
35
 	{ MODKEY,                    XKB_KEY_l,          setmfact,       {.f = +0.05f} },
36
+	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_h,          incgaps,       {.i = +1 } },
37
+	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_l,          incgaps,       {.i = -1 } },
38
+	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT,   XKB_KEY_H,      incogaps,      {.i = +1 } },
39
+	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT,   XKB_KEY_L,      incogaps,      {.i = -1 } },
40
+	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL,    XKB_KEY_h,      incigaps,      {.i = +1 } },
41
+	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_CTRL,    XKB_KEY_l,      incigaps,      {.i = -1 } },
42
+	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_0,          togglegaps,     {0} },
43
+	{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT,   XKB_KEY_parenright,defaultgaps,    {0} },
44
+	{ MODKEY,                    XKB_KEY_y,          incihgaps,     {.i = +1 } },
45
+	{ MODKEY,                    XKB_KEY_o,          incihgaps,     {.i = -1 } },
46
+	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_y,          incivgaps,     {.i = +1 } },
47
+	{ MODKEY|WLR_MODIFIER_CTRL,  XKB_KEY_o,          incivgaps,     {.i = -1 } },
48
+	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_y,          incohgaps,     {.i = +1 } },
49
+	{ MODKEY|WLR_MODIFIER_LOGO,  XKB_KEY_o,          incohgaps,     {.i = -1 } },
50
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y,          incovgaps,     {.i = +1 } },
51
+	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O,          incovgaps,     {.i = -1 } },
52
 	{ MODKEY,                    XKB_KEY_Return,     zoom,           {0} },
53
 	{ MODKEY,                    XKB_KEY_Tab,        view,           {0} },
54
 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C,          killclient,     {0} },
55
diff --git a/dwl.c b/dwl.c
56
index ad21e1ba..fa823957 100644
57
--- a/dwl.c
58
+++ b/dwl.c
59
@@ -197,6 +197,10 @@ struct Monitor {
60
 	struct wlr_box w; /* window area, layout-relative */
61
 	struct wl_list layers[4]; /* LayerSurface.link */
62
 	const Layout *lt[2];
63
+	int gappih;           /* horizontal gap between windows */
64
+	int gappiv;           /* vertical gap between windows */
65
+	int gappoh;           /* horizontal outer gaps */
66
+	int gappov;           /* vertical outer gaps */
67
 	unsigned int seltags;
68
 	unsigned int sellt;
69
 	uint32_t tagset[2];
70
@@ -271,6 +275,7 @@ static void createpopup(struct wl_listener *listener, void *data);
71
 static void cursorconstrain(struct wlr_pointer_constraint_v1 *constraint);
72
 static void cursorframe(struct wl_listener *listener, void *data);
73
 static void cursorwarptohint(void);
74
+static void defaultgaps(const Arg *arg);
75
 static void destroydecoration(struct wl_listener *listener, void *data);
76
 static void destroydragicon(struct wl_listener *listener, void *data);
77
 static void destroyidleinhibitor(struct wl_listener *listener, void *data);
78
@@ -290,6 +295,13 @@ static void fullscreennotify(struct wl_listener *listener, void *data);
79
 static void gpureset(struct wl_listener *listener, void *data);
80
 static void handlesig(int signo);
81
 static void incnmaster(const Arg *arg);
82
+static void incgaps(const Arg *arg);
83
+static void incigaps(const Arg *arg);
84
+static void incihgaps(const Arg *arg);
85
+static void incivgaps(const Arg *arg);
86
+static void incogaps(const Arg *arg);
87
+static void incohgaps(const Arg *arg);
88
+static void incovgaps(const Arg *arg);
89
 static void inputdevice(struct wl_listener *listener, void *data);
90
 static int keybinding(uint32_t mods, xkb_keysym_t sym);
91
 static void keypress(struct wl_listener *listener, void *data);
92
@@ -323,6 +335,7 @@ static void setcursor(struct wl_listener *listener, void *data);
93
 static void setcursorshape(struct wl_listener *listener, void *data);
94
 static void setfloating(Client *c, int floating);
95
 static void setfullscreen(Client *c, int fullscreen);
96
+static void setgaps(int oh, int ov, int ih, int iv);
97
 static void setlayout(const Arg *arg);
98
 static void setmfact(const Arg *arg);
99
 static void setmon(Client *c, Monitor *m, uint32_t newtags);
100
@@ -336,6 +349,7 @@ static void tagmon(const Arg *arg);
101
 static void tile(Monitor *m);
102
 static void togglefloating(const Arg *arg);
103
 static void togglefullscreen(const Arg *arg);
104
+static void togglegaps(const Arg *arg);
105
 static void toggletag(const Arg *arg);
106
 static void toggleview(const Arg *arg);
107
 static void unlocksession(struct wl_listener *listener, void *data);
108
@@ -405,6 +419,7 @@ static struct wlr_output_layout *output_layout;
109
 static struct wlr_box sgeom;
110
 static struct wl_list mons;
111
 static Monitor *selmon;
112
+static int enablegaps = 1;   /* enables gaps, used by togglegaps */
113
 
114
 /* global event handlers */
115
 static struct wl_listener cursor_axis = {.notify = axisnotify};
116
@@ -1048,6 +1063,11 @@ createmon(struct wl_listener *listener, void *data)
117
 	for (i = 0; i < LENGTH(m->layers); i++)
118
 		wl_list_init(&m->layers[i]);
119
 
120
+	m->gappih = gappih;
121
+	m->gappiv = gappiv;
122
+	m->gappoh = gappoh;
123
+	m->gappov = gappov;
124
+
125
 	wlr_output_state_init(&state);
126
 	/* Initialize monitor state using configured rules */
127
 	m->tagset[0] = m->tagset[1] = 1;
128
@@ -1230,6 +1250,12 @@ cursorwarptohint(void)
129
 	}
130
 }
131
 
132
+void
133
+defaultgaps(const Arg *arg)
134
+{
135
+	setgaps(gappoh, gappov, gappih, gappiv);
136
+}
137
+
138
 void
139
 destroydecoration(struct wl_listener *listener, void *data)
140
 {
141
@@ -1566,6 +1592,83 @@ incnmaster(const Arg *arg)
142
 	arrange(selmon);
143
 }
144
 
145
+void
146
+incgaps(const Arg *arg)
147
+{
148
+	setgaps(
149
+		selmon->gappoh + arg->i,
150
+		selmon->gappov + arg->i,
151
+		selmon->gappih + arg->i,
152
+		selmon->gappiv + arg->i
153
+	);
154
+}
155
+
156
+void
157
+incigaps(const Arg *arg)
158
+{
159
+	setgaps(
160
+		selmon->gappoh,
161
+		selmon->gappov,
162
+		selmon->gappih + arg->i,
163
+		selmon->gappiv + arg->i
164
+	);
165
+}
166
+
167
+void
168
+incihgaps(const Arg *arg)
169
+{
170
+	setgaps(
171
+		selmon->gappoh,
172
+		selmon->gappov,
173
+		selmon->gappih + arg->i,
174
+		selmon->gappiv
175
+	);
176
+}
177
+
178
+void
179
+incivgaps(const Arg *arg)
180
+{
181
+	setgaps(
182
+		selmon->gappoh,
183
+		selmon->gappov,
184
+		selmon->gappih,
185
+		selmon->gappiv + arg->i
186
+	);
187
+}
188
+
189
+void
190
+incogaps(const Arg *arg)
191
+{
192
+	setgaps(
193
+		selmon->gappoh + arg->i,
194
+		selmon->gappov + arg->i,
195
+		selmon->gappih,
196
+		selmon->gappiv
197
+	);
198
+}
199
+
200
+void
201
+incohgaps(const Arg *arg)
202
+{
203
+	setgaps(
204
+		selmon->gappoh + arg->i,
205
+		selmon->gappov,
206
+		selmon->gappih,
207
+		selmon->gappiv
208
+	);
209
+}
210
+
211
+void
212
+incovgaps(const Arg *arg)
213
+{
214
+	setgaps(
215
+		selmon->gappoh,
216
+		selmon->gappov + arg->i,
217
+		selmon->gappih,
218
+		selmon->gappiv
219
+	);
220
+}
221
+
222
 void
223
 inputdevice(struct wl_listener *listener, void *data)
224
 {
225
@@ -2357,6 +2460,16 @@ setfullscreen(Client *c, int fullscreen)
226
 	printstatus();
227
 }
228
 
229
+void
230
+setgaps(int oh, int ov, int ih, int iv)
231
+{
232
+	selmon->gappoh = MAX(oh, 0);
233
+	selmon->gappov = MAX(ov, 0);
234
+	selmon->gappih = MAX(ih, 0);
235
+	selmon->gappiv = MAX(iv, 0);
236
+	arrange(selmon);
237
+}
238
+
239
 void
240
 setlayout(const Arg *arg)
241
 {
242
@@ -2701,7 +2814,7 @@ tagmon(const Arg *arg)
243
 void
244
 tile(Monitor *m)
245
 {
246
-	unsigned int mw, my, ty;
247
+	unsigned int mw, my, ty, h, r, oe = enablegaps, ie = enablegaps;
248
 	int i, n = 0;
249
 	Client *c;
250
 
251
@@ -2711,22 +2824,31 @@ tile(Monitor *m)
252
 	if (n == 0)
253
 		return;
254
 
255
+	if (smartgaps == n) {
256
+		oe = 0; // outer gaps disabled
257
+	}
258
+
259
 	if (n > m->nmaster)
260
-		mw = m->nmaster ? (int)roundf(m->w.width * m->mfact) : 0;
261
+		mw = m->nmaster ? (int)roundf((m->w.width + m->gappiv*ie) * m->mfact) : 0;
262
 	else
263
-		mw = m->w.width;
264
-	i = my = ty = 0;
265
+		mw = m->w.width - 2*m->gappov*oe + m->gappiv*ie;
266
+	i = 0;
267
+	my = ty = m->gappoh*oe;
268
 	wl_list_for_each(c, &clients, link) {
269
 		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
270
 			continue;
271
 		if (i < m->nmaster) {
272
-			resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
273
-				.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
274
-			my += c->geom.height;
275
+			r = MIN(n, m->nmaster) - i;
276
+			h = (m->w.height - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
277
+			resize(c, (struct wlr_box){.x = m->w.x + m->gappov*oe, .y = m->w.y + my,
278
+				.width = mw - m->gappiv*ie, .height = h}, 0);
279
+			my += c->geom.height + m->gappih*ie;
280
 		} else {
281
-			resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
282
-				.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
283
-			ty += c->geom.height;
284
+			r = n - i;
285
+			h = (m->w.height - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r;
286
+			resize(c, (struct wlr_box){.x = m->w.x + mw + m->gappov*oe, .y = m->w.y + ty,
287
+				.width = m->w.width - mw - 2*m->gappov*oe, .height = h}, 0);
288
+			ty += c->geom.height + m->gappih*ie;
289
 		}
290
 		i++;
291
 	}
292
@@ -2749,6 +2871,13 @@ togglefullscreen(const Arg *arg)
293
 		setfullscreen(sel, !sel->isfullscreen);
294
 }
295
 
296
+void
297
+togglegaps(const Arg *arg)
298
+{
299
+	enablegaps = !enablegaps;
300
+	arrange(selmon);
301
+}
302
+
303
 void
304
 toggletag(const Arg *arg)
305
 {
306
-- 
307
2.48.0
308
309
310
From e3d10f01df9b7d6735ce9e43ebfdca35b8639f0e Mon Sep 17 00:00:00 2001
311
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
312
 <leohdz172@protonmail.com>
313
Date: Wed, 20 Jul 2022 00:15:32 -0500
314
Subject: [PATCH 2/2] allow gaps in monocle layout if requested
315
MIME-Version: 1.0
316
Content-Type: text/plain; charset=UTF-8
317
Content-Transfer-Encoding: 8bit
318
319
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
320
---
321
 config.def.h | 1 +
322
 dwl.c        | 6 +++++-
323
 2 files changed, 6 insertions(+), 1 deletion(-)
324
325
diff --git a/config.def.h b/config.def.h
326
index 39e528b1..f4d4095d 100644
327
--- a/config.def.h
328
+++ b/config.def.h
329
@@ -7,6 +7,7 @@
330
 static const int sloppyfocus               = 1;  /* focus follows mouse */
331
 static const int bypass_surface_visibility = 0;  /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible  */
332
 static const int smartgaps                 = 0;  /* 1 means no outer gap when there is only one window */
333
+static const int monoclegaps               = 0;  /* 1 means outer gaps in monocle layout */
334
 static const unsigned int borderpx         = 1;  /* border pixel of windows */
335
 static const unsigned int gappih           = 10; /* horiz inner gap between windows */
336
 static const unsigned int gappiv           = 10; /* vert inner gap between windows */
337
diff --git a/dwl.c b/dwl.c
338
index fa823957..59eabb54 100644
339
--- a/dwl.c
340
+++ b/dwl.c
341
@@ -1922,8 +1922,12 @@ monocle(Monitor *m)
342
 	wl_list_for_each(c, &clients, link) {
343
 		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
344
 			continue;
345
-		resize(c, m->w, 0);
346
 		n++;
347
+		if (!monoclegaps)
348
+			resize(c, m->w, 0);
349
+		else
350
+			resize(c, (struct wlr_box){.x = m->w.x + gappoh, .y = m->w.y + gappov,
351
+				.width = m->w.width - 2 * gappoh, .height = m->w.height - 2 * gappov}, 0);
352
 	}
353
 	if (n)
354
 		snprintf(m->ltsymbol, LENGTH(m->ltsymbol), "[%d]", n);
355
-- 
356
2.48.0