From 42ced86afdaf5cd40bca9976f96e6bef0ca711b0 Mon Sep 17 00:00:00 2001
From: Joe <rbo@gmx.us>
Date: Sun, 2 Mar 2025 00:49:58 +0100
Subject: grid and rainbows and its good

---
 patches/applied/dwm-rainbowtags-6.2.diff | 59 +++++++++++++++++++++
 patches/applied/gaplessgrid.patch        | 89 ++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+)
 create mode 100644 patches/applied/dwm-rainbowtags-6.2.diff
 create mode 100644 patches/applied/gaplessgrid.patch

(limited to 'patches/applied')

diff --git a/patches/applied/dwm-rainbowtags-6.2.diff b/patches/applied/dwm-rainbowtags-6.2.diff
new file mode 100644
index 0000000..6c31062
--- /dev/null
+++ b/patches/applied/dwm-rainbowtags-6.2.diff
@@ -0,0 +1,59 @@
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..3fb5cf8 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -21,6 +21,18 @@ static const char *colors[][3]      = {
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+ 
++static const char *tagsel[][2] = {
++	{ "#ffffff", "#ff0000" },
++	{ "#ffffff", "#ff7f00" },
++	{ "#000000", "#ffff00" },
++	{ "#000000", "#00ff00" },
++	{ "#ffffff", "#0000ff" },
++	{ "#ffffff", "#4b0082" },
++	{ "#ffffff", "#9400d3" },
++	{ "#000000", "#ffffff" },
++	{ "#ffffff", "#000000" },
++};
++
+ static const Rule rules[] = {
+ 	/* xprop(1):
+ 	 *	WM_CLASS(STRING) = instance, class
+diff --git a/dwm.c b/dwm.c
+index b0b3466..c16d5f5 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -264,6 +264,7 @@ static Atom wmatom[WMLast], netatom[NetLast];
+ static int running = 1;
+ static Cur *cursor[CurLast];
+ static Clr **scheme;
++static Clr **tagscheme;
+ static Display *dpy;
+ static Drw *drw;
+ static Monitor *mons, *selmon;
+@@ -717,7 +718,7 @@ drawbar(Monitor *m)
+ 	x = 0;
+ 	for (i = 0; i < LENGTH(tags); i++) {
+ 		w = TEXTW(tags[i]);
+-		drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
++		drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeNorm]));
+ 		drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+ 		if (occ & 1 << i)
+ 			drw_rect(drw, x + boxs, boxs, boxw, boxw,
+@@ -1568,9 +1569,14 @@ setup(void)
+ 	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
+ 	cursor[CurMove] = drw_cur_create(drw, XC_fleur);
+ 	/* init appearance */
++	if (LENGTH(tags) > LENGTH(tagsel))
++		die("too few color schemes for the tags");
+ 	scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
+ 	for (i = 0; i < LENGTH(colors); i++)
+ 		scheme[i] = drw_scm_create(drw, colors[i], 3);
++	tagscheme = ecalloc(LENGTH(tagsel), sizeof(Clr *));
++	for (i = 0; i < LENGTH(tagsel); i++)
++		tagscheme[i] = drw_scm_create(drw, tagsel[i], 2);
+ 	/* init bars */
+ 	updatebars();
+ 	updatestatus();
diff --git a/patches/applied/gaplessgrid.patch b/patches/applied/gaplessgrid.patch
new file mode 100644
index 0000000..2af1072
--- /dev/null
+++ b/patches/applied/gaplessgrid.patch
@@ -0,0 +1,89 @@
+diff --git a/config.def.h b/config.def.h
+index 22d2171..014a909 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -34,6 +34,7 @@ static const Layout layouts[] = {
+ 	{ "[]=",      tile },
+ 	{ "><>",      NULL },    /* no layout function means floating behavior */
+ 	{ "[M]",      monocle },
++	{ "###",      gaplessgrid },
+ };
+ 
+ /* monitors */
+@@ -139,6 +140,7 @@ static const Key keys[] = {
+ 	{ MODKEY,                    XKB_KEY_t,          setlayout,      {.v = &layouts[0]} },
+ 	{ MODKEY,                    XKB_KEY_f,          setlayout,      {.v = &layouts[1]} },
+ 	{ MODKEY,                    XKB_KEY_m,          setlayout,      {.v = &layouts[2]} },
++	{ MODKEY,                    XKB_KEY_g,          setlayout,      {.v = &layouts[3]} },
+ 	{ MODKEY,                    XKB_KEY_space,      setlayout,      {0} },
+ 	{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space,      togglefloating, {0} },
+ 	{ MODKEY,                    XKB_KEY_e,         togglefullscreen, {0} },
+diff --git a/dwl.c b/dwl.c
+index dc0c861..875d8cd 100644
+--- a/dwl.c
++++ b/dwl.c
+@@ -292,6 +292,7 @@ static void focusstack(const Arg *arg);
+ static Client *focustop(Monitor *m);
+ static void fullscreennotify(struct wl_listener *listener, void *data);
+ static void gpureset(struct wl_listener *listener, void *data);
++static void gaplessgrid(Monitor *m);
+ static void handlesig(int signo);
+ static void incnmaster(const Arg *arg);
+ static void inputdevice(struct wl_listener *listener, void *data);
+@@ -1510,6 +1511,56 @@ handlesig(int signo)
+ 	}
+ }
+ 
++void
++gaplessgrid(Monitor *m)
++{
++	unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
++	Client *c;
++
++	wl_list_for_each(c, &clients, link)
++		if (VISIBLEON(c, m) && !c->isfloating)
++			n++;
++	if (n == 0)
++		return;
++
++	/* grid dimensions */
++	for (cols = 0; cols <= (n / 2); cols++)
++		if ((cols * cols) >= n)
++			break;
++
++	if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
++		cols = 2;
++
++    /* widescreen is better if 3 columns */
++    if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
++        cols = 3;
++
++	rows = n / cols;
++    
++	/* window geometries */
++	cw = cols ? m->w.width / cols : m->w.width;
++	cn = 0; /* current column number */
++	rn = 0; /* current row number */
++	wl_list_for_each(c, &clients, link) {
++		unsigned int cx, cy;
++		if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
++			continue;
++
++		if ((i / rows + 1) > (cols - n % cols))
++			rows = n / cols + 1;
++		ch = rows ? m->w.height / rows : m->w.height;
++		cx = m->w.x + cn * cw;
++		cy = m->w.y + rn * ch;
++		resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
++		rn++;
++		if (rn >= rows) {
++			rn = 0;
++			cn++;
++		}
++		i++;
++	}
++}
++
+ void
+ incnmaster(const Arg *arg)
+ {
-- 
cgit v1.2.3