summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Rumbaugh <doug@douglasrumbaugh.com>2021-12-26 20:23:48 -0500
committerDouglas Rumbaugh <doug@douglasrumbaugh.com>2021-12-26 20:23:48 -0500
commiteac52b126417c38a4d95de0118bdd02f74153ccb (patch)
treee51e37f33a7165068176fda2cc022f70afcd704c
parent1537d444a39ec88e41f2c97c05b598b42acb9bd4 (diff)
downloaddwm-eac52b126417c38a4d95de0118bdd02f74153ccb.tar.gz
Applied movestack patch
http://dwm.suckless.org/patches/movestack/
-rw-r--r--config.def.h5
-rw-r--r--movestack.c48
2 files changed, 52 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h
index 504c587..960f90d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -186,6 +186,7 @@ ResourcePref resources[] = {
};
#include <X11/XF86keysym.h>
+#include "movestack.c"
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
@@ -198,6 +199,8 @@ static Key keys[] = {
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_space, zoom, {0} },
+ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
/*
{ MODKEY|Mod4Mask, XK_u, incrgaps, {.i = +1 } },
@@ -264,7 +267,7 @@ static Key keys[] = {
{ 0, XF86XK_AudioMicMute, spawn, SHCMD("pactl set-source-mute @DEFAULT_SOURCE@ toggle") },
{ 0, XF86XK_PowerOff, spawn, SHCMD("sysact") },
{ 0, XF86XK_Calculator, spawn, SHCMD("st -e bc -l") },
- { 0, XF86XK_Sleep, spawn, SHCMD("slock systemctl sleep -i") },
+ { 0, XF86XK_Sleep, spawn, SHCMD("systemctl suspend") },
{ 0, XF86XK_WWW, spawn, SHCMD("$BROWSER") },
{ 0, XF86XK_DOS, spawn, SHCMD("st") },
{ 0, XF86XK_ScreenSaver, spawn, SHCMD("slock & xset dpms force off; mpc pause; pauseallmpv") },
diff --git a/movestack.c b/movestack.c
new file mode 100644
index 0000000..520f4ae
--- /dev/null
+++ b/movestack.c
@@ -0,0 +1,48 @@
+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);
+ }
+} \ No newline at end of file