dwm

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

commit 1582e97de4e6b085bfa2c4ea481d66e594219e30
parent b35f1abc14f7b863dc193346c603a050fa72298f
Author: kocotian <kocotian@kocotian.pl>
Date:   Sat, 12 Dec 2020 13:25:44 +0100

tags and stack tweakin patches

Diffstat:
Mconfig.def.h | 6+++++-
Mconfig.def.h.orig | 4++++
Mconfig.def.h.rej | 51+++++++++++++++++++++++++++++++++++++++++++--------
Mdwm.c | 23+++++++++++++++++++++++
Amovestack.c | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Mpatches/dwm-movestack-6.1.diff | 0
Mpatches/dwm-swaptags-6.2.diff | 0
7 files changed, 124 insertions(+), 9 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -75,7 +75,8 @@ static const Direction directions[] = { { 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} }, \ + { MODKEY|ShiftMask|Mod1Mask, KEY, swaptags, {.ui = 1 << TAG} }, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } @@ -85,6 +86,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +#include "movestack.c" static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_Tab, view, {0} }, @@ -103,6 +105,8 @@ static Key keys[] = { { MODKEY, XK_f, togglefullscr, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY|ShiftMask, XK_h, setcfact, {.f = -0.25} }, diff --git a/config.def.h.orig b/config.def.h.orig @@ -85,6 +85,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +#include "movestack.c" static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_Tab, view, {0} }, @@ -100,8 +101,11 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_o, incnmaster, {.i = -1 } }, { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_f, togglefullscr, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY|ShiftMask, XK_h, setcfact, {.f = -0.25} }, diff --git a/config.def.h.rej b/config.def.h.rej @@ -1,10 +1,45 @@ --- config.def.h +++ config.def.h -@@ -78,6 +78,7 @@ static Key keys[] = { - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, -+ { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, +@@ -43,13 +43,16 @@ static const Layout layouts[] = { + { "[M]", monocle }, + }; + ++void swaptags(const Arg *arg); ++ + /* key definitions */ + #define MODKEY Mod1Mask + #define TAGKEYS(KEY,TAG) \ + { 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} }, \ ++ { Mod4Mask|ShiftMask, KEY, swaptags, {.ui = 1 << TAG} }, + + /* helper for spawning shell commands in the pre dwm-5.0 fashion */ + #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } +@@ -113,3 +116,24 @@ static Button buttons[] = { + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + }; + ++void ++swaptags(const Arg *arg) ++{ ++ unsigned int newtag = arg->ui & TAGMASK; ++ unsigned int curtag = selmon->tagset[selmon->seltags]; ++ ++ if (newtag == curtag || !curtag || (curtag & (curtag-1))) ++ return; ++ ++ for (Client *c = selmon->clients; c != NULL; c = c->next) { ++ if((c->tags & newtag) || (c->tags & curtag)) ++ c->tags ^= curtag ^ newtag; ++ ++ if(!c->tags) c->tags = newtag; ++ } ++ ++ selmon->tagset[selmon->seltags] = newtag; ++ ++ focus(NULL); ++ arrange(selmon); ++} diff --git a/dwm.c b/dwm.c @@ -243,6 +243,7 @@ static void sigchld(int unused); static void sighup(int unused); static void sigterm(int unused); static void spawn(const Arg *arg); +static void swaptags(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *); @@ -1986,6 +1987,28 @@ spawn(const Arg *arg) } void +swaptags(const Arg *arg) +{ + unsigned int newtag = arg->ui & TAGMASK; + unsigned int curtag = selmon->tagset[selmon->seltags]; + + if (newtag == curtag || !curtag || (curtag & (curtag-1))) + return; + + for (Client *c = selmon->clients; c != NULL; c = c->next) { + if((c->tags & newtag) || (c->tags & curtag)) + c->tags ^= curtag ^ newtag; + + if(!c->tags) c->tags = newtag; + } + + selmon->tagset[selmon->seltags] = newtag; + + focus(NULL); + arrange(selmon); +} + +void tag(const Arg *arg) { if (selmon->sel && arg->ui & TAGMASK) { diff --git a/movestack.c b/movestack.c @@ -0,0 +1,49 @@ +void +movestack(const Arg *arg) { + Client *c = NULL, *p = NULL, *pc = NULL, *i; + + if(arg->i > 0) { + /* find the client after selmon->sel */ + for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); + if(!c) + for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next); + + } + else { + /* find the client before selmon->sel */ + for(i = selmon->clients; i != selmon->sel; i = i->next) + if(ISVISIBLE(i) && !i->isfloating) + c = i; + if(!c) + for(; i; i = i->next) + if(ISVISIBLE(i) && !i->isfloating) + c = i; + } + /* find the client before selmon->sel and c */ + for(i = selmon->clients; i && (!p || !pc); i = i->next) { + if(i->next == selmon->sel) + p = i; + if(i->next == c) + pc = i; + } + + /* swap c and selmon->sel selmon->clients in the selmon->clients list */ + if(c && c != selmon->sel) { + Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next; + selmon->sel->next = c->next==selmon->sel?c:c->next; + c->next = temp; + + if(p && p != c) + p->next = c; + if(pc && pc != selmon->sel) + pc->next = selmon->sel; + + if(selmon->sel == selmon->clients) + selmon->clients = c; + else if(c == selmon->clients) + selmon->clients = selmon->sel; + + arrange(selmon); + } +} + diff --git a/patches/dwm-movestack-6.1.diff b/patches/dwm-movestack-6.1.diff diff --git a/patches/dwm-swaptags-6.2.diff b/patches/dwm-swaptags-6.2.diff