dwm

my heavily-patched and customized dwm build
git clone git://git.kocotian.pl/dwm.git
Log | Files | Refs | README | LICENSE

commit 32addc1f0285ee9071ff38639f61c8df77624cc8
parent 8e637749590e73ab33336ea41b2c5783df108e06
Author: kocotian <kocotian@kocotian.pl>
Date:   Sun, 24 Jan 2021 11:49:06 +0100

smartgaps

Diffstat:
Mconfig.def.h | 7++++---
Mdwm.c | 21+++++++++++++--------
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -6,14 +6,15 @@ static void modmove(const Arg *arg); /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int smartgaps = 1; /* smart gaps */ +static const unsigned int ogappx = 30; /* outer gaps */ +static const unsigned int igappx = 3; /* inner gaps */ static const int swallowfloating = 0; /* 1 means swallow floating windows by default */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char statussep = ';'; /* separator between status bars */ static const int barheight = 25; /* height of a bar; 0 equals autocalculation */ static const int attachdirection = 0; /* 0 default, 1 above, 2 aside, 3 below, 4 bottom, 5 top */ -static const int ogappx = 30; -static const int igappx = 3; static const char *fonts[] = { "monospace:size=8", "JoyPixels:pixelsize=10:antialias=true:autohint=true" }; static const char dmenufont[] = "monospace:size=8"; static const char col_gray1[] = "#222222"; @@ -199,7 +200,7 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_bracketright, spawn, SHCMD("mpc seek +60") }, { MODKEY, XK_a, gaptog, {0} }, - { MODKEY|ShiftMask, XK_a, spawn, SHCMD("st -e htop") }, + { MODKEY|ShiftMask, XK_a, gaptog, {1} }, { MODKEY, XK_d, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_d, spawn, SHCMD("dmenize") }, { MODKEY, XK_f, togglefullscr, {0} }, diff --git a/dwm.c b/dwm.c @@ -144,7 +144,7 @@ struct Monitor { int eby; /* extra bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ - unsigned int ogappx, igappx; + unsigned int smartgaps, ogappx, igappx; unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -959,8 +959,9 @@ createmon(void) strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); strncpy(m->attsymbol, directions[attachdirection].symbol, strlen(directions[attachdirection].symbol) + 1); - m->ogappx = ogappx; - m->igappx = igappx; + m->smartgaps = smartgaps; + m->ogappx = ogappx; + m->igappx = igappx; m->pertag = ecalloc(1, sizeof(Pertag)); m->pertag->curtag = m->pertag->prevtag = 1; @@ -2324,10 +2325,14 @@ setogappx(const Arg *arg) void gaptog(const Arg *arg) { - if (selmon->ogappx == ogappx && selmon->igappx == igappx) { - selmon->ogappx = 0; selmon->igappx = 0; - } else { - selmon->ogappx = ogappx; selmon->igappx = igappx; + if (arg->i) + selmon->smartgaps = !selmon->smartgaps; + else { + if (selmon->ogappx == ogappx && selmon->igappx == igappx) { + selmon->ogappx = 0; selmon->igappx = 0; + } else { + selmon->ogappx = ogappx; selmon->igappx = igappx; + } } arrange(selmon); } @@ -2556,7 +2561,7 @@ tile(Monitor *m) if (i < m->nmaster) { h = (m->wh - my) * (c->cfact / mfacts); if (n <= m->nmaster) - resize(c, m->wx + m->ogappx, m->wy + my + m->ogappx, mw - (2*c->bw) - (2*m->ogappx), h - (2*c->bw) - (2*m->ogappx), 0); + resize(c, m->wx + (!m->smartgaps*m->ogappx), m->wy + my + (!m->smartgaps*m->ogappx), mw - (2*c->bw) - (!m->smartgaps*(2*m->ogappx)), h - (2*c->bw) - (!m->smartgaps*(2*m->ogappx)), 0); else resize(c, m->wx + m->ogappx, m->wy + my + m->ogappx, mw - (2*c->bw) - m->ogappx - m->igappx, h - (2*c->bw) - (2*m->ogappx), 0); if (my + HEIGHT(c) < m->wh)