sites

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

commit ff9725d4b3c46d6461d34be4c324348330b309ad
parent 2d66c35e4633398dcae4a00ffcc7a98dc7b9191b
Author: sesankm <26676400+sesankm@users.noreply.github.com>
Date:   Tue, 30 Sep 2025 15:30:56 -0500

patch for dwm to show gaps when one window is open

Diffstat:
Adwm.suckless.org/patches/singlegap/dwm-singlegap-6.6.diff | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/singlegap/index.md | 16++++++++++++++++
2 files changed, 139 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/singlegap/dwm-singlegap-6.6.diff b/dwm.suckless.org/patches/singlegap/dwm-singlegap-6.6.diff @@ -0,0 +1,123 @@ +From d0b1b523a1cf4901aa848e20a9fff59154b3f3c8 Mon Sep 17 00:00:00 2001 +From: sesankm <26676400+sesankm@users.noreply.github.com> +Date: Tue, 30 Sep 2025 14:29:08 -0500 +Subject: [PATCH] Add gaps when only one window is open + +--- + config.def.h | 8 +++++--- + dwm.c | 33 +++++++++++++++++++++++---------- + 2 files changed, 28 insertions(+), 13 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 81c3fc0..b6a0b7d 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,8 @@ + + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ ++static const unsigned int gapx = 120; /* horizontal gap */ ++static const unsigned int gapy = 40; /* vertical gap */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ +@@ -26,9 +28,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 isfloating monitor disablegap */ ++ { "Gimp", NULL, NULL, 0, 1, -1, 0}, ++ { "Firefox", NULL, NULL, 1 << 8, 0, -1, 1}, + }; + + /* layout(s) */ +diff --git a/dwm.c b/dwm.c +index 4f345ee..1633c38 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 disablegaps; + Client *next; + Client *snext; + Monitor *mon; +@@ -138,6 +139,7 @@ typedef struct { + unsigned int tags; + int isfloating; + int monitor; ++ int disablegaps; + } Rule; + + /* function declarations */ +@@ -286,6 +288,7 @@ applyrules(Client *c) + /* rule matching */ + c->isfloating = 0; + c->tags = 0; ++ c->disablegaps = 0; + XGetClassHint(dpy, c->win, &ch); + class = ch.res_class ? ch.res_class : broken; + instance = ch.res_name ? ch.res_name : broken; +@@ -302,6 +305,8 @@ applyrules(Client *c) + if (m) + c->mon = m; + } ++ if (strstr(class, r->class) || strstr(instance, r->class)) ++ c->disablegaps = r->disablegaps; + } + if (ch.res_class) + XFree(ch.res_class); +@@ -1686,28 +1691,36 @@ tagmon(const Arg *arg) + void + tile(Monitor *m) + { +- unsigned int i, n, h, mw, my, ty; ++ unsigned int i, n, h, mw, my, ty, ns, gx = 0, gy = 0; + Client *c; + ++ + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; ++ else if (n == 1 && ((nexttiled(m->clients)))->disablegaps == 0) { ++ gx = gapx; ++ gy = gapy; ++ } + +- if (n > m->nmaster) ++ if (n > m->nmaster) { + mw = m->nmaster ? m->ww * m->mfact : 0; +- else ++ ns = m->nmaster > 0 ? 2 : 1; ++ } else { + mw = m->ww; +- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ ns = 1; ++ } ++ for(i = 0, my = ty = gy, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { +- h = (m->wh - my) / (MIN(n, m->nmaster) - i); +- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); ++ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - gy; ++ resize(c, m->wx + gx, m->wy + my, mw - (2*c->bw) - gx*(5-ns)/2, h - (2*c->bw), False); + if (my + HEIGHT(c) < m->wh) +- my += HEIGHT(c); ++ my += HEIGHT(c) + gy; + } else { +- h = (m->wh - ty) / (n - i); +- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); ++ h = (m->wh - ty) / (n - i) - gy; ++ resize(c, m->wx + mw + gx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - gx*(5-ns)/2, h - (2*c->bw), False); + if (ty + HEIGHT(c) < m->wh) +- ty += HEIGHT(c); ++ ty += HEIGHT(c) + gy; + } + } + +-- +2.49.1 + diff --git a/dwm.suckless.org/patches/singlegap/index.md b/dwm.suckless.org/patches/singlegap/index.md @@ -0,0 +1,16 @@ +singlegap +========= + +Description +----------- +This modifies the tilegap patch and shows gaps only when there is a single +window open. Exclusions can be added and horizontal/vertical gaps can be +configured in config.h. + +Download +-------- +* [dwm-singlegap-6.6.diff](dwm-singlegap-6.6.diff) (20250930) + +Author +------ +* sesankm