sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 9fd6d17e232b36312d7454464ab48b29de9a5200
parent 10e2c6e834051815915ebb85ed27f88e883e0e1b
Author: Niky Kovalski <nikykovalski@gmail.com>
Date:   Fri, 11 Sep 2026 20:35:48 -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

Diffstat:
Adwm.suckless.org/patches/centeronlywindow/dwm-centeronlywindow-20260911-44dbc68.diff | 78++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/centeronlywindow/index.md | 29+++++++++++++++++++++++++++++
2 files changed, 107 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/centeronlywindow/dwm-centeronlywindow-20260911-44dbc68.diff b/dwm.suckless.org/patches/centeronlywindow/dwm-centeronlywindow-20260911-44dbc68.diff @@ -0,0 +1,78 @@ +From 71c84fd35126ffdaa64bf79b55b0b984476d9a75 Mon Sep 17 00:00:00 2001 +From: Niky Kovalski <nikykovalski@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 +@@ -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 +@@ -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; +@@ -137,6 +138,7 @@ typedef struct { + const char *title; + unsigned int tags; + int isfloating; ++ int iscenteredalone; + int monitor; + } Rule; + +@@ -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; +@@ -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) +@@ -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 @@ -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@gmail.com>