[wiki] [sites] add centeronlywindow patch || Niky Kovalski
commit 9fd6d17e232b36312d7454464ab48b29de9a5200
Author: Niky Kovalski <nikykovalski_AT_gmail.com>
Date: Fri Sep 11 20:35:48 2026 -0400
add centeronlywindow patch
add a patch which adds a rule which centers a window in tiled mode
if it is the only window in tiled mode
add dwm-centeronlywindow-20260911-44dbc68.diff and index.md files
diff --git a/dwm.suckless.org/patches/centeronlywindow/dwm-centeronlywindow-20260911-44dbc68.diff b/dwm.suckless.org/patches/centeronlywindow/dwm-centeronlywindow-20260911-44dbc68.diff
new file mode 100644
index 00000000..8aa95588
--- /dev/null
+++ b/dwm.suckless.org/patches/centeronlywindow/dwm-centeronlywindow-20260911-44dbc68.diff
_AT_@ -0,0 +1,78 @@
+From 71c84fd35126ffdaa64bf79b55b0b984476d9a75 Mon Sep 17 00:00:00 2001
+From: Niky Kovalski <nikykovalski_AT_gmail.com>
+Date: Fri, 11 Sep 2026 17:25:04 -0400
+Subject: [PATCH] centeronlywindow
+
+add a rule to center a window in tiled mode when it is the only window
+---
+ config.def.h | 7 ++++---
+ dwm.c | 7 +++++++
+ 2 files changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 81c3fc0..84f36c1 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -26,9 +26,10 @@ 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 isfloating iscenteredalone monitor */
++ { "st", NULL, NULL, 0, 1, 1, -1 },
++ { "Gimp", NULL, NULL, 0, 1, 0, -1 },
++ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
+ };
+
+ /* layout(s) */
+diff --git a/dwm.c b/dwm.c
+index ab3a84c..2710c1f 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -92,6 +92,7 @@ struct Client {
+ int bw, oldbw;
+ unsigned int tags;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
++ int iscenteredalone;
+ Client *next;
+ Client *snext;
+ Monitor *mon;
+_AT_@ -137,6 +138,7 @@ typedef struct {
+ const char *title;
+ unsigned int tags;
+ int isfloating;
++ int iscenteredalone;
+ int monitor;
+ } Rule;
+
+_AT_@ -285,6 +287,7 @@ applyrules(Client *c)
+
+ /* rule matching */
+ c->isfloating = 0;
++ c->iscenteredalone = 0;
+ c->tags = 0;
+ XGetClassHint(dpy, c->win, &ch);
+ class = ch.res_class ? ch.res_class : broken;
+_AT_@ -297,6 +300,7 @@ applyrules(Client *c)
+ && (!r->instance || strstr(instance, r->instance)))
+ {
+ c->isfloating = r->isfloating;
++ c->iscenteredalone = r->iscenteredalone;
+ c->tags |= r->tags;
+ for (m = mons; m && m->num != r->monitor; m = m->next);
+ if (m)
+_AT_@ -1710,6 +1714,9 @@ tile(Monitor *m)
+ if (ty + HEIGHT(c) < m->wh)
+ ty += HEIGHT(c);
+ }
++
++ if (n == 1 && (c = nexttiled(m->clients))->iscenteredalone)
++ resizeclient(c, m->mw / 4, m->mh / 4, m->mw / 2, m->mh / 2);
+ }
+
+ void
+--
+2.55.0
+
diff --git a/dwm.suckless.org/patches/centeronlywindow/index.md b/dwm.suckless.org/patches/centeronlywindow/index.md
new file mode 100644
index 00000000..f347cfb3
--- /dev/null
+++ b/dwm.suckless.org/patches/centeronlywindow/index.md
_AT_@ -0,0 +1,29 @@
+center only window
+==================
+
+Description
+-----------
+This patch adds a rule which centers a window in tiled mode
+when it is the only window. When more than one window is open
+in tiled mode, then they tile normally.
+
+ +-----------------------+ +-----------+-----------+
+ | | | | |
+ | +-----------+ | | | |
+ | | | | | | |
+ | | 1 | | | 1 | 2 |
+ | | | | | | |
+ | +-----------+ | | | |
+ | | | | |
+ +-----------------------+ +-----------+-----------+
+
+Replaces [centerfirstwindow](../center_first_window) which doesn't
+work as expected.
+
+Download
+--------
+* [dwm-centeronlywindow-20260911-44dbc68.diff](dwm-centeronlywindow-20260911-44dbc68.diff)
+
+Authors
+-------
+Niky Kovalski <nikykovalski_AT_gmail.com>
Received on Sat Sep 12 2026 - 02:37:46 CEST
This archive was generated by hypermail 2.3.0
: Sat Sep 12 2026 - 02:48:51 CEST