dwm

[fork] dynamic window manager
Log | Files | Refs | README | LICENSE

commit b9567a2f0fe69bd3d29c4d4cb7d221123edd4e36
parent 282e6dead34fbe89a939a19b6bb78b58f9442fd6
Author: hhvn <hayden@haydenvh.com>
Date:   Sun, 22 Nov 2020 23:03:10 +0000

dwm.c config.h: revise layout activation

Diffstat:
Mconfig.h | 74++++++++++++++++++++++++++++++++++++--------------------------------------
Mdwm.c | 4+---
2 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/config.h b/config.h @@ -39,13 +39,13 @@ static const int resizehints = 0; /* 1 means respect size hints in tiled resi static const Layout layouts[] = { /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "\\f/", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, - { "[@]", spiral }, - { "[#=-]", dwindle }, - { "[SMS]", centeredmaster }, - { "[\\M/]", centeredfloatingmaster }, + { "|=", tile }, /* first entry is default */ + { ".:", NULL }, /* no layout function means floating behavior */ + { "M", monocle }, + { "@", spiral }, + { "#=", dwindle }, + { "=#=", centeredmaster }, + { "=:=", centeredfloatingmaster }, }; /* key definitions */ @@ -55,44 +55,42 @@ static const Layout layouts[] = { { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, +#define LAYOUT(KEY, LAYOUT) \ + { MODKEY|AltMask, KEY, setlayout, {.v = &layouts[LAYOUT]} }, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } -static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static char *dmenucmd[] = { NULL }; - static Key keys[] = { /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Return, zoom, {0} }, - /*{ MODKEY, XK_space, setlayout, {0} },*/ - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY, XK_f, togglefullscr, {0} }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_i, incnmaster, {.i = +1 } }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, - { MODKEY, XK_l, setmfact, {.f = +0.05 } }, - { MODKEY, XK_p, incnmaster, {.i = -1 } }, - { MODKEY, XK_q, killclient, {0} }, - { MODKEY|ShiftMask, XK_q, quit, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_Return, zoom, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY, XK_f, togglefullscr, {0} }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_l, setmfact, {.f = +0.05 } }, + { MODKEY, XK_p, incnmaster, {.i = -1 } }, + { MODKEY, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_q, quit, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, /* Layout */ - { MODKEY|AltMask, XK_1, setlayout, {.v = &layouts[0]} }, - { MODKEY|AltMask, XK_2, setlayout, {.v = &layouts[1]} }, - { MODKEY|AltMask, XK_3, setlayout, {.v = &layouts[3]} }, - { MODKEY|AltMask, XK_4, setlayout, {.v = &layouts[4]} }, - { MODKEY|AltMask, XK_5, setlayout, {.v = &layouts[5]} }, - { MODKEY|AltMask, XK_6, setlayout, {.v = &layouts[6]} }, - { MODKEY|AltMask, XK_7, setlayout, {.v = &layouts[7]} }, - { MODKEY|AltMask, XK_0, setlayout, {.v = &layouts[2]} }, + LAYOUT( XK_1, 0) + LAYOUT( XK_2, 1) + LAYOUT( XK_3, 3) + LAYOUT( XK_4, 4) + LAYOUT( XK_5, 5) + LAYOUT( XK_6, 6) + LAYOUT( XK_7, 7) + LAYOUT( XK_0, 2) /* Tags */ TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) diff --git a/dwm.c b/dwm.c @@ -1204,7 +1204,7 @@ monocle(Monitor *m) if (ISVISIBLE(c)) n++; if (n > 0) /* override layout symbol */ - snprintf(m->ltsymbol, sizeof m->ltsymbol, "[M%d]", n); + snprintf(m->ltsymbol, sizeof m->ltsymbol, "M%d", n); for (c = nexttiled(m->clients); c; c = nexttiled(c->next)) resize(c, m->wx + m->gappx, m->wy + m->gappx, (m->ww - 2 * c->bw) - 2*m->gappx, (m->wh - 2 * c->bw) - 2*m->gappx, 0); } @@ -1640,8 +1640,6 @@ sigchld(int unused) void spawn(const Arg *arg) { - if (arg->v == dmenucmd) - dmenumon[0] = '0' + selmon->num; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy));