From 2724e7627329fc7d252e1c2da088df7138044354 Mon Sep 17 00:00:00 2001 From: Sascha Paunovic Date: Sun, 17 Dec 2017 12:29:14 +0100 Subject: [PATCH] add new layouts --- config.h | 9 +++++++-- fibonacci.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 fibonacci.c diff --git a/config.h b/config.h index 4185dc4..b9dd800 100644 --- a/config.h +++ b/config.h @@ -1,4 +1,5 @@ #include "X11/XF86keysym.h" +#include "fibonacci.c" /* See LICENSE file for copyright and license details. */ /* appearance */ static const unsigned int borderpx = 1; /* border pixel of windows */ @@ -46,6 +47,8 @@ static const Layout layouts[] = { { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[\\]", dwindle }, + { "[/]", spiral }, }; /* key definitions */ @@ -64,7 +67,7 @@ static char dmenumon[2] = "0"; /* component of dmenu, 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 *passmenucmd[] = {"passmenu", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *term[] = {"st", NULL }; -static const char *brow[] = {"apulse", "firefox", NULL }; +static const char *brow[] = {"firefox", NULL }; static const char *play[] = {"mpc", "play", NULL }; static const char *vold[] = {"amixer", "-q", "set", "Master", "5%-", "unmute", NULL}; static const char *volu[] = {"amixer", "-q", "set", "Master", "5%+", "unmute", NULL}; @@ -74,7 +77,7 @@ static const char *next[] = {"mpc", "next", NULL}; static const char *prev[] = {"mpc", "prev", NULL}; static const char *togg[] = {"mpc", "toggle", NULL}; static const char *lock[] = {"slock", NULL}; -static const char *lokk[] = {"lokk", NULL}; +static const char *lokk[] = {"slock", "&&", "zzz", NULL}; static Key keys[] = { /* modifier key function argument */ @@ -104,6 +107,8 @@ 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, XK_q, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_w, setlayout, {.v = &layouts[4]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, 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); +} -- 2.11.4.GIT