From f9104b06153ff2b5f6db50ba828b2dccaffe49cc Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 8 May 2019 07:10:53 +0100 Subject: [PATCH 01/18] Applies the movestack patch --- config.def.h | 3 +++ movestack.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 movestack.c diff --git a/config.def.h b/config.def.h index 1c0b587..ebeb3f4 100644 --- a/config.def.h +++ b/config.def.h @@ -59,6 +59,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_p, spawn, {.v = dmenucmd } }, @@ -66,6 +67,8 @@ static Key keys[] = { { MODKEY, XK_b, togglebar, {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_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, diff --git a/movestack.c b/movestack.c new file mode 100644 index 0000000..c040462 --- /dev/null +++ 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); + } +} + From 41c868c3b4a85f3ed62de2de9c528658a73b20b0 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 8 May 2019 07:13:42 +0100 Subject: [PATCH 02/18] Adds the shifting options to the man page --- dwm.1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dwm.1 b/dwm.1 index 13b3729..e001a25 100644 --- a/dwm.1 +++ b/dwm.1 @@ -98,6 +98,12 @@ Focus next window. .B Mod1\-k Focus previous window. .TP +.B Mod1\-Shift\-j +Moves the focused window down in the stack +.TP +.B Mod1\-Shift\-k +Moves the focused window up in the stack +.TP .B Mod1\-i Increase number of windows in master area. .TP From bdc4d25b7af384533e17fb47c2acceb7126dfd34 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 8 May 2019 08:44:28 +0100 Subject: [PATCH 03/18] Makes screenshot and qutebrowser work --- config.def.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h index c0aad25..27116ad 100644 --- a/config.def.h +++ b/config.def.h @@ -27,8 +27,8 @@ static const Rule rules[] = { * WM_NAME(STRING) = title */ /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + { "Gimp", NULL, NULL, 0, 0, -1 }, + //{ "Firefox", NULL, NULL, 1 << 8, 0, -1 }, }; /* layout(s) */ @@ -61,9 +61,11 @@ static const char *dmenucmd[] = { "rofi", "-show", "drun", NULL }; //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[] = { "folder-shell", NULL }; -static const char *fullscreenshot[] = { "scrot", "/tmp/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL }; -static const char *activescreenshot[] = { "scrot", "-u", "/tmp/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL }; -static const char *selectscreenshot[] = { "scrot", "-s", "/tmp/%F_%T_$wx$h.png", "-e", "xclip -selection clipboard -target image/png -i $f", NULL }; +static const char *fullscreenshot[] = { "screenshot", NULL }; +static const char *activescreenshot[] = { "screenshot", "window", NULL }; +static const char *selectscreenshot[] = { "screenshot", "select", NULL }; + +static const char *qutebrowser[] = { "qutebrowser", NULL }; #include "movestack.c" static Key keys[] = { @@ -93,9 +95,11 @@ static Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - { MODKEY, XK_Print, spawn, {.v = fullscreenshot } }, + { 0, XK_Print, spawn, {.v = fullscreenshot } }, { ControlMask, XK_Print, spawn, {.v = activescreenshot } }, { ShiftMask, XK_Print, spawn, {.v = selectscreenshot } }, + //Applications + { MODKEY|ShiftMask, XK_q, spawn, {.v = qutebrowser } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) From e3594813917e8b8a162c701162432c9ee24a3551 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 16 May 2019 10:51:50 +0100 Subject: [PATCH 04/18] Adds greenclip and date shortcuts --- config.def.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config.def.h b/config.def.h index 27116ad..ab4cdc1 100644 --- a/config.def.h +++ b/config.def.h @@ -65,8 +65,12 @@ static const char *fullscreenshot[] = { "screenshot", NULL }; static const char *activescreenshot[] = { "screenshot", "window", NULL }; static const char *selectscreenshot[] = { "screenshot", "select", NULL }; +static const char *greenclip[] = { "rofi", "-modi", "clipboard:greenclip print", "-show", "clipboard", "-run-command", "{cmd}", NULL }; + static const char *qutebrowser[] = { "qutebrowser", NULL }; +static const char *date[] = { "datetime", NULL }; + #include "movestack.c" static Key keys[] = { /* modifier key function argument */ @@ -98,6 +102,8 @@ static Key keys[] = { { 0, XK_Print, spawn, {.v = fullscreenshot } }, { ControlMask, XK_Print, spawn, {.v = activescreenshot } }, { ShiftMask, XK_Print, spawn, {.v = selectscreenshot } }, + { MODKEY|ShiftMask, XK_d, spawn, {.v = date } }, + { MODKEY|ShiftMask, XK_Insert, spawn, {.v = greenclip } }, //Applications { MODKEY|ShiftMask, XK_q, spawn, {.v = qutebrowser } }, TAGKEYS( XK_1, 0) From 8a9ab337626ae1ce2640aec45bbee9a5e64c234e Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 20 May 2019 18:41:37 +0100 Subject: [PATCH 05/18] Adds tripple col layout --- config.def.h | 4 +++ tcl.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 tcl.c diff --git a/config.def.h b/config.def.h index ab4cdc1..2410373 100644 --- a/config.def.h +++ b/config.def.h @@ -37,11 +37,14 @@ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ static const int attachbelow = 1; /* 1 means attach after the currently active window */ +#include "tcl.c" + static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "|||", tcl }, }; /* key definitions */ @@ -91,6 +94,7 @@ static Key keys[] = { { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[3]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/tcl.c b/tcl.c new file mode 100644 index 0000000..72967d3 --- /dev/null +++ b/tcl.c @@ -0,0 +1,74 @@ +void +tcl(Monitor * m) +{ + int x, y, h, w, mw, sw, bdw; + unsigned int i, n; + Client * c; + + for (n = 0, c = nexttiled(m->clients); c; + c = nexttiled(c->next), n++); + + if (n == 0) + return; + + c = nexttiled(m->clients); + + mw = m->mfact * m->ww; + sw = (m->ww - mw) / 2; + bdw = (2 * c->bw); + resize(c, + n < 3 ? m->wx : m->wx + sw, + m->wy, + n == 1 ? m->ww - bdw : mw - bdw, + m->wh - bdw, + False); + + if (--n == 0) + return; + + w = (m->ww - mw) / ((n > 1) + 1); + c = nexttiled(c->next); + + if (n > 1) + { + x = m->wx + ((n > 1) ? mw + sw : mw); + y = m->wy; + h = m->wh / (n / 2); + + if (h < bh) + h = m->wh; + + for (i = 0; c && i < n / 2; c = nexttiled(c->next), i++) + { + resize(c, + x, + y, + w - bdw, + (i + 1 == n / 2) ? m->wy + m->wh - y - bdw : h - bdw, + False); + + if (h != m->wh) + y = c->y + HEIGHT(c); + } + } + + x = (n + 1 / 2) == 1 ? mw : m->wx; + y = m->wy; + h = m->wh / ((n + 1) / 2); + + if (h < bh) + h = m->wh; + + for (i = 0; c; c = nexttiled(c->next), i++) + { + resize(c, + x, + y, + (i + 1 == (n + 1) / 2) ? w - bdw : w - bdw, + (i + 1 == (n + 1) / 2) ? m->wy + m->wh - y - bdw : h - bdw, + False); + + if (h != m->wh) + y = c->y + HEIGHT(c); + } +} From d07d47ccb874bc79d9197e47aba2c32b8a652d29 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 23 May 2019 19:30:40 +0100 Subject: [PATCH 06/18] Adds binding for play/pause --- config.def.h | 92 ++++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/config.def.h b/config.def.h index 2410373..4e3a05c 100644 --- a/config.def.h +++ b/config.def.h @@ -1,5 +1,8 @@ /* See LICENSE file for copyright and license details. */ +//The media and volume keys +#include "X11/XF86keysym.h" + /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ @@ -74,52 +77,55 @@ static const char *qutebrowser[] = { "qutebrowser", NULL }; static const char *date[] = { "datetime", NULL }; +static const char *playpause[] = { "playerctl", "play-pause", NULL }; + #include "movestack.c" static Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, - { MODKEY, XK_Return, spawn, {.v = termcmd } }, - { MODKEY, XK_b, togglebar, {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_i, incnmaster, {.i = +1 } }, - { MODKEY, XK_d, incnmaster, {.i = -1 } }, - { MODKEY, XK_h, setmfact, {.f = -0.05} }, - { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY|ShiftMask, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY, XK_q, killclient, {0} }, - { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[3]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {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 } }, - { 0, XK_Print, spawn, {.v = fullscreenshot } }, - { ControlMask, XK_Print, spawn, {.v = activescreenshot } }, - { ShiftMask, XK_Print, spawn, {.v = selectscreenshot } }, - { MODKEY|ShiftMask, XK_d, spawn, {.v = date } }, - { MODKEY|ShiftMask, XK_Insert, spawn, {.v = greenclip } }, + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_b, togglebar, {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_i, incnmaster, {.i = +1 } }, + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY, XK_q, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {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 } }, + { 0, XK_Print, spawn, {.v = fullscreenshot } }, + { ControlMask, XK_Print, spawn, {.v = activescreenshot } }, + { ShiftMask, XK_Print, spawn, {.v = selectscreenshot } }, + { 0, XF86XK_AudioPlay, spawn, {.v = playpause } }, + { MODKEY|ShiftMask, XK_d, spawn, {.v = date } }, + { MODKEY|ShiftMask, XK_Insert, spawn, {.v = greenclip } }, //Applications - { MODKEY|ShiftMask, XK_q, spawn, {.v = qutebrowser } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_r, quit, {0} }, + { MODKEY|ShiftMask, XK_q, spawn, {.v = qutebrowser } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_r, quit, {0} }, }; /* button definitions */ From 7cc04ac97d2bc87815e942b8b5a2fdd91e8bb583 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Thu, 23 May 2019 19:34:48 +0100 Subject: [PATCH 07/18] Applies the fakefullscreen patch --- dwm.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/dwm.c b/dwm.c index 4465af1..2e469ad 100644 --- a/dwm.c +++ b/dwm.c @@ -521,7 +521,7 @@ clientmessage(XEvent *e) if (cme->data.l[1] == netatom[NetWMFullscreen] || cme->data.l[2] == netatom[NetWMFullscreen]) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ - || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); + || cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */)); } else if (cme->message_type == netatom[NetActiveWindow]) { if (c != selmon->sel && !c->isurgent) seturgent(c, 1); @@ -551,7 +551,6 @@ void configurenotify(XEvent *e) { Monitor *m; - Client *c; XConfigureEvent *ev = &e->xconfigure; int dirty; @@ -564,9 +563,6 @@ configurenotify(XEvent *e) drw_resize(drw, sw, bh); updatebars(); for (m = mons; m; m = m->next) { - for (c = m->clients; c; c = c->next) - if (c->isfullscreen) - resizeclient(c, m->mx, m->my, m->mw, m->mh); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); } focus(NULL); @@ -1143,8 +1139,6 @@ movemouse(const Arg *arg) if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ - return; restack(selmon); ocx = c->x; ocy = c->y; @@ -1298,8 +1292,6 @@ resizemouse(const Arg *arg) if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ - return; restack(selmon); ocx = c->x; ocy = c->y; @@ -1476,24 +1468,10 @@ setfullscreen(Client *c, int fullscreen) XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); c->isfullscreen = 1; - c->oldstate = c->isfloating; - c->oldbw = c->bw; - c->bw = 0; - c->isfloating = 1; - resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); - XRaiseWindow(dpy, c->win); } else if (!fullscreen && c->isfullscreen){ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)0, 0); c->isfullscreen = 0; - c->isfloating = c->oldstate; - c->bw = c->oldbw; - c->x = c->oldx; - c->y = c->oldy; - c->w = c->oldw; - c->h = c->oldh; - resizeclient(c, c->x, c->y, c->w, c->h); - arrange(c->mon); } } @@ -1618,7 +1596,7 @@ showhide(Client *c) if (ISVISIBLE(c)) { /* show clients top down */ XMoveWindow(dpy, c->win, c->x, c->y); - if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) + if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, 0); showhide(c->snext); } else { @@ -1710,8 +1688,6 @@ togglefloating(const Arg *arg) { if (!selmon->sel) return; - if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ - return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, From 7c01eac9a7e543a78240c36e254a51ea2907aed7 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 28 May 2019 15:40:54 +0100 Subject: [PATCH 08/18] Adds shortcut for lock / shutdown --- config.def.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.def.h b/config.def.h index 4e3a05c..04fbe36 100644 --- a/config.def.h +++ b/config.def.h @@ -79,6 +79,8 @@ static const char *date[] = { "datetime", NULL }; static const char *playpause[] = { "playerctl", "play-pause", NULL }; +static const char *logout[] = { "rofi-shutdown", NULL }; + #include "movestack.c" static Key keys[] = { /* modifier key function argument */ @@ -93,6 +95,7 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_l, spawn, {.v = logout} }, { MODKEY|ShiftMask, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, From e73c4b4391ee773a32919cad88e5965b0af78c73 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 28 May 2019 16:58:33 +0100 Subject: [PATCH 09/18] Stops atatch after --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 04fbe36..42bd34c 100644 --- a/config.def.h +++ b/config.def.h @@ -38,7 +38,7 @@ static const Rule rules[] = { static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ -static const int attachbelow = 1; /* 1 means attach after the currently active window */ +static const int attachbelow = 0; /* 1 means attach after the currently active window */ #include "tcl.c" From 8c445b5368af2ea0f95fd70e4e4b2735573ffc21 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 28 May 2019 17:01:46 +0100 Subject: [PATCH 10/18] Applies the fibonachi patch --- config.def.h | 3 +++ fibonacci.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 fibonacci.c diff --git a/config.def.h b/config.def.h index 1c0b587..f5e4bf1 100644 --- a/config.def.h +++ b/config.def.h @@ -36,11 +36,14 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95] static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ +#include "fibonacci.c" static const Layout layouts[] = { /* symbol arrange function */ { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[@]", spiral }, + { "[\\]", dwindle }, }; /* key definitions */ diff --git a/fibonacci.c b/fibonacci.c new file mode 100644 index 0000000..fce0a57 --- /dev/null +++ b/fibonacci.c @@ -0,0 +1,66 @@ +void +fibonacci(Monitor *mon, int s) { + unsigned int i, n, nx, ny, nw, nh; + Client *c; + + for(n = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next), n++); + if(n == 0) + return; + + nx = mon->wx; + ny = 0; + nw = mon->ww; + nh = mon->wh; + + for(i = 0, c = nexttiled(mon->clients); c; c = nexttiled(c->next)) { + if((i % 2 && nh / 2 > 2 * c->bw) + || (!(i % 2) && nw / 2 > 2 * c->bw)) { + if(i < n - 1) { + if(i % 2) + nh /= 2; + else + nw /= 2; + if((i % 4) == 2 && !s) + nx += nw; + else if((i % 4) == 3 && !s) + ny += nh; + } + if((i % 4) == 0) { + if(s) + ny += nh; + else + ny -= nh; + } + else if((i % 4) == 1) + nx += nw; + else if((i % 4) == 2) + ny += nh; + else if((i % 4) == 3) { + if(s) + nx += nw; + else + nx -= nw; + } + if(i == 0) + { + if(n != 1) + nw = mon->ww * mon->mfact; + ny = mon->wy; + } + else if(i == 1) + nw = mon->ww - nw; + i++; + } + resize(c, nx, ny, nw - 2 * c->bw, nh - 2 * c->bw, False); + } +} + +void +dwindle(Monitor *mon) { + fibonacci(mon, 1); +} + +void +spiral(Monitor *mon) { + fibonacci(mon, 0); +} From e6218d57b89432c188885eac956c986a2f5bae29 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 29 May 2019 19:40:39 +0100 Subject: [PATCH 11/18] Adds shortcut for fibonachi layout --- config.def.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index afc73c8..a5c2aea 100644 --- a/config.def.h +++ b/config.def.h @@ -50,7 +50,7 @@ static const Layout layouts[] = { { "[M]", monocle }, { "|||", tcl }, { "[@]", spiral }, - { "[\\]", dwindle }, + { "[\\]", dwindle }, }; /* key definitions */ @@ -103,9 +103,10 @@ static Key keys[] = { { MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[4]} }, + { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[5]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, From 362b95a5b9f91673f27f3e3343b5738df3c9d6e9 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Sun, 2 Jun 2019 15:11:57 +0100 Subject: [PATCH 12/18] Allows attach below to be toggled --- config.def.h | 2 +- dwm.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index cb8053a..b4d35aa 100644 --- a/config.def.h +++ b/config.def.h @@ -35,7 +35,7 @@ static const Rule rules[] = { static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ -static const int attachbelow = 1; /* 1 means attach after the currently active window */ +static int attachbelow = 1; /* 1 means attach after the currently active window */ static const Layout layouts[] = { /* symbol arrange function */ diff --git a/dwm.c b/dwm.c index bd715a2..5d88653 100644 --- a/dwm.c +++ b/dwm.c @@ -148,6 +148,7 @@ static void arrange(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); static void attachBelow(Client *c); +static void toggleAttachBelow(); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void checkotherwm(void); @@ -422,6 +423,11 @@ attachBelow(Client *c) } +void toggleAttachBelow() +{ + attachbelow = !attachbelow; +} + void attachstack(Client *c) { From 046b66b1d614883e8987d4a1fa9b0a0890c813d6 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Sun, 2 Jun 2019 17:48:06 +0100 Subject: [PATCH 13/18] Fix typo --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index e99f5d2..c96b6a0 100644 --- a/config.def.h +++ b/config.def.h @@ -99,7 +99,7 @@ static Key keys[] = { { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY|ShiftMask, XK_l, spawn, {.v = logout} }, { MODKEY|ShiftMask, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, toggleattachbelow, {0} }, + { MODKEY, XK_Tab, toggleAttachBelow, {0} }, { MODKEY, XK_q, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, From a83a15527c64c660e04a64378267f278941c473a Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 11 Jun 2019 14:19:42 +0100 Subject: [PATCH 14/18] Makes attach below a variable int --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index c96b6a0..c600f1c 100644 --- a/config.def.h +++ b/config.def.h @@ -38,7 +38,7 @@ static const Rule rules[] = { static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 0; /* 1 means respect size hints in tiled resizals */ -static const int attachbelow = 0; /* 1 means attach after the currently active window */ +static int attachbelow = 0; /* 1 means attach after the currently active window */ #include "tcl.c" #include "fibonacci.c" From 7004f485f5bfed9a355271a2baae45dd72bd2aaa Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Tue, 11 Jun 2019 14:23:57 +0100 Subject: [PATCH 15/18] Adds swallow patch --- config.def.h | 7 +- config.mk | 2 +- dwm.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 190 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 1c0b587..0a7302f 100644 --- a/config.def.h +++ b/config.def.h @@ -26,9 +26,10 @@ 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 isterminal noswallow monitor */ + { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, + { "st", NULL, NULL, 0, 0, 1, 1, -1 }, }; /* layout(s) */ diff --git a/config.mk b/config.mk index 6d36cb7..5e93cfd 100644 --- a/config.mk +++ b/config.mk @@ -22,7 +22,7 @@ FREETYPEINC = /usr/include/freetype2 # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lX11-xcb -lxcb -lxcb-res # flags CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/dwm.c b/dwm.c index 4465af1..d594e01 100644 --- a/dwm.c +++ b/dwm.c @@ -40,6 +40,8 @@ #include #endif /* XINERAMA */ #include +#include +#include #include "drw.h" #include "util.h" @@ -92,9 +94,11 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; + pid_t pid; Client *next; Client *snext; + Client *swallowing; Monitor *mon; Window win; }; @@ -138,6 +142,8 @@ typedef struct { const char *title; unsigned int tags; int isfloating; + int isterminal; + int noswallow; int monitor; } Rule; @@ -234,6 +240,13 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); +static pid_t getparentprocess(pid_t p); +static int isdescprocess(pid_t p, pid_t c); +static Client *swallowingclient(Window w); +static Client *termforwin(const Client *c); +static pid_t winpid(Window w); + + /* variables */ static const char broken[] = "broken"; static char stext[256]; @@ -268,6 +281,8 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; +static xcb_connection_t *xcon; + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -297,6 +312,7 @@ applyrules(Client *c) && (!r->class || strstr(class, r->class)) && (!r->instance || strstr(instance, r->instance))) { + c->isterminal = r->isterminal; c->isfloating = r->isfloating; c->tags |= r->tags; for (m = mons; m && m->num != r->monitor; m = m->next); @@ -413,6 +429,47 @@ attachstack(Client *c) c->mon->stack = c; } +void +swallow(Client *p, Client *c) +{ + if (c->noswallow || c->isterminal) + return; + + detach(c); + detachstack(c); + + setclientstate(c, WithdrawnState); + XUnmapWindow(dpy, p->win); + + p->swallowing = c; + c->mon = p->mon; + + Window w = p->win; + p->win = c->win; + c->win = w; + updatetitle(p); + arrange(p->mon); + XMoveResizeWindow(dpy, p->win, p->x, p->y, p->w, p->h); + configure(p); + updateclientlist(); +} + +void +unswallow(Client *c) +{ + c->win = c->swallowing->win; + + free(c->swallowing); + c->swallowing = NULL; + + updatetitle(c); + arrange(c->mon); + XMapWindow(dpy, c->win); + XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); + configure(c); + setclientstate(c, NormalState); +} + void buttonpress(XEvent *e) { @@ -652,6 +709,9 @@ destroynotify(XEvent *e) if ((c = wintoclient(ev->window))) unmanage(c, 1); + + else if ((c = swallowingclient(ev->window))) + unmanage(c->swallowing, 1); } void @@ -1017,12 +1077,13 @@ killclient(const Arg *arg) void manage(Window w, XWindowAttributes *wa) { - Client *c, *t = NULL; + Client *c, *t = NULL, *term = NULL; Window trans = None; XWindowChanges wc; c = ecalloc(1, sizeof(Client)); c->win = w; + c->pid = winpid(w); /* geometry */ c->x = c->oldx = wa->x; c->y = c->oldy = wa->y; @@ -1037,6 +1098,7 @@ manage(Window w, XWindowAttributes *wa) } else { c->mon = selmon; applyrules(c); + term = termforwin(c); } if (c->x + WIDTH(c) > c->mon->mx + c->mon->mw) @@ -1073,6 +1135,8 @@ manage(Window w, XWindowAttributes *wa) c->mon->sel = c; arrange(c->mon); XMapWindow(dpy, c->win); + if (term) + swallow(term, c); focus(NULL); } @@ -1765,6 +1829,20 @@ unmanage(Client *c, int destroyed) Monitor *m = c->mon; XWindowChanges wc; + if (c->swallowing) { + unswallow(c); + return; + } + + Client *s = swallowingclient(c->win); + if (s) { + free(s->swallowing); + s->swallowing = NULL; + arrange(m); + focus(NULL); + return; + } + detach(c); detachstack(c); if (!destroyed) { @@ -1779,9 +1857,12 @@ unmanage(Client *c, int destroyed) XUngrabServer(dpy); } free(c); - focus(NULL); - updateclientlist(); - arrange(m); + + if (!s) { + arrange(m); + focus(NULL); + updateclientlist(); + } } void @@ -2044,6 +2125,103 @@ view(const Arg *arg) arrange(selmon); } +pid_t +winpid(Window w) +{ + pid_t result = 0; + + xcb_res_client_id_spec_t spec = {0}; + spec.client = w; + spec.mask = XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID; + + xcb_generic_error_t *e = NULL; + xcb_res_query_client_ids_cookie_t c = xcb_res_query_client_ids(xcon, 1, &spec); + xcb_res_query_client_ids_reply_t *r = xcb_res_query_client_ids_reply(xcon, c, &e); + + if (!r) + return (pid_t)0; + + xcb_res_client_id_value_iterator_t i = xcb_res_query_client_ids_ids_iterator(r); + for (; i.rem; xcb_res_client_id_value_next(&i)) { + spec = i.data->spec; + if (spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) { + uint32_t *t = xcb_res_client_id_value_value(i.data); + result = *t; + break; + } + } + + free(r); + + if (result == (pid_t)-1) + result = 0; + return result; +} + +pid_t +getparentprocess(pid_t p) +{ + unsigned int v = 0; + +#ifdef __linux__ + FILE *f; + char buf[256]; + snprintf(buf, sizeof(buf) - 1, "/proc/%u/stat", (unsigned)p); + + if (!(f = fopen(buf, "r"))) + return 0; + + fscanf(f, "%*u %*s %*c %u", &v); + fclose(f); +#endif /* __linux__ */ + + return (pid_t)v; +} + +int +isdescprocess(pid_t p, pid_t c) +{ + while (p != c && c != 0) + c = getparentprocess(c); + + return (int)c; +} + +Client * +termforwin(const Client *w) +{ + Client *c; + Monitor *m; + + if (!w->pid || w->isterminal) + return NULL; + + for (m = mons; m; m = m->next) { + for (c = m->clients; c; c = c->next) { + if (c->isterminal && !c->swallowing && c->pid && isdescprocess(c->pid, w->pid)) + return c; + } + } + + return NULL; +} + +Client * +swallowingclient(Window w) +{ + Client *c; + Monitor *m; + + for (m = mons; m; m = m->next) { + for (c = m->clients; c; c = c->next) { + if (c->swallowing && c->swallowing->win == w) + return c; + } + } + + return NULL; +} + Client * wintoclient(Window w) { @@ -2135,6 +2313,8 @@ main(int argc, char *argv[]) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); + if (!(xcon = XGetXCBConnection(dpy))) + die("dwm: cannot get xcb connection\n"); checkotherwm(); setup(); #ifdef __OpenBSD__ From 27e95ed9e256383c06b8a99b4256bbe1c10820e5 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 12 Jun 2019 09:32:36 +0100 Subject: [PATCH 16/18] Makes terminal swallow applications opened from it --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 9bc64e6..1a660ed 100644 --- a/config.def.h +++ b/config.def.h @@ -32,7 +32,7 @@ static const Rule rules[] = { /* class instance title tags mask isfloating isterminal noswallow monitor */ { "Gimp", NULL, NULL, 0, 0, 0, 0, -1 }, //{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, - { "st", NULL, NULL, 0, 0, 1, 1, -1 }, + { "xterm-256color", NULL, NULL, 0, 0, 1, 1, -1 }, }; /* layout(s) */ From 902b0c87a8a4fd9cccee07c5c093ec4a2d2dc678 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Fri, 14 Jun 2019 13:51:45 +0100 Subject: [PATCH 17/18] Makes thundirbird always open on tag 9 --- config.def.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 1a660ed..fe94a95 100644 --- a/config.def.h +++ b/config.def.h @@ -29,10 +29,11 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating isterminal noswallow monitor */ - { "Gimp", NULL, NULL, 0, 0, 0, 0, -1 }, - //{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, - { "xterm-256color", NULL, NULL, 0, 0, 1, 1, -1 }, + /* class instance title tags mask isfloating isterminal noswallow monitor */ + //{ "Gimp", NULL, NULL, 0, 0, 0, 0, -1 }, + //{ "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, + { "xterm-256color", NULL, NULL, 0, 0, 1, 1, -1 }, + { "Thunderbird", NULL, NULL, 1 << 8 , 0, 0, 0, -1 }, }; /* layout(s) */ From e72ceef4ef47e7bcd5ec73d4b0412c931a7d4653 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 22 Jul 2019 17:20:31 +0100 Subject: [PATCH 18/18] Change font --- config.def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index fe94a95..ec31940 100644 --- a/config.def.h +++ b/config.def.h @@ -8,8 +8,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 0; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; +static const char *fonts[] = { "Iosevka:size=10" }; +static const char dmenufont[] = "Iosevka:size=10"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb";