From a9855f8d3e2dd159c0e384b758278444b4293ddc Mon Sep 17 00:00:00 2001 From: odweta Date: Tue, 26 May 2026 10:50:56 +0200 Subject: [PATCH] add: alpha for st & new layouts for dwm --- dwm/config.def.h | 14 ++- dwm/config.def.h.orig | 153 +++++++++++++++++------------- dwm/config.def.h.rej | 65 +++++-------- dwm/config.h | 14 ++- dwm/fibonacci.c | 66 +++++++++++++ dwm/patches/dwm-02-fibonacci.diff | 115 ++++++++++++++++++++++ st/config.def.h | 3 + st/config.def.h.orig | 2 + st/config.h | 3 + st/patches/st-05-alpha.diff | 130 +++++++++++++++++++++++++ st/x.c | 44 +++++++-- st/x.c.orig | 3 + 12 files changed, 486 insertions(+), 126 deletions(-) create mode 100644 dwm/fibonacci.c create mode 100644 dwm/patches/dwm-02-fibonacci.diff create mode 100644 st/patches/st-05-alpha.diff diff --git a/dwm/config.def.h b/dwm/config.def.h index 4d207bc..7f98dec 100644 --- a/dwm/config.def.h +++ b/dwm/config.def.h @@ -51,6 +51,8 @@ static const Rule rules[] = { { NULL, "keepassxc", NULL, SPTAG(2), 1, -1 }, { NULL, "spnmtui", NULL, SPTAG(3), 1, -1 }, { NULL, "spmusic", NULL, SPTAG(4), 1, -1 }, + { "st-256color", NULL, NULL, 1 << 0, 0, -1 }, + { "firefox", NULL, NULL, 1 << 1, 0, -1 }, }; /* layout(s) */ @@ -60,11 +62,14 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */ +#include "fibonacci.c" static const Layout layouts[] = { /* symbol arrange function */ + { "[\\]", dwindle }, { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[@]", spiral }, }; /* key definitions */ @@ -87,7 +92,7 @@ static const char *djcmd[] = { "dj.sh", NULL }; static const Key keys[] = { /* modifier key function argument */ // essential apps - { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_m, spawn, {.v = djcmd } }, // window management @@ -96,17 +101,15 @@ static const Key keys[] = { { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_q, killclient, {0} }, - { MODKEY, XK_space, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_f, togglefloating, {0} }, // focus change (tags and monitors) - //{ 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 } }, // scratchpads { MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0 } }, // ephemeral term - { MODKEY|ShiftMask, XK_f, togglescratch, {.ui = 1 } }, // file manager + { MODKEY, XK_f, togglescratch, {.ui = 1 } }, // file manager { MODKEY, XK_p, togglescratch, {.ui = 2 } }, // keepass { MODKEY, XK_n, togglescratch, {.ui = 3 } }, // nmtui { MODKEY|ShiftMask, XK_m, togglescratch, {.ui = 4 } }, // music @@ -120,6 +123,7 @@ static const Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) +// misc { MODKEY|ShiftMask, XK_e, quit, {0} }, }; diff --git a/dwm/config.def.h.orig b/dwm/config.def.h.orig index ab031ca..4d207bc 100644 --- a/dwm/config.def.h.orig +++ b/dwm/config.def.h.orig @@ -14,21 +14,43 @@ static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_main[] = "#735e97"; static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_main, col_main }, + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_main, col_main }, +}; + +typedef struct { + const char *name; + const void *cmd; +} Sp; +const char *spcmd0[] = {"st", "-n", "spterm", "-g", "120x34", NULL }; +const char *spcmd1[] = {"st", "-n", "spfm", "-g", "144x41", "-e", "lf", NULL }; +const char *spcmd2[] = {"keepassxc", NULL }; +const char *spcmd3[] = {"st", "-n", "spnmtui", "-g", "140x30", "-e", "nmtui", NULL }; +const char *spcmd4[] = {"st", "-n", "spmusic", "-g", "140x30", "-e", "ncmpcpp", NULL }; +static Sp scratchpads[] = { + /* name cmd */ + {"spterm", spcmd0}, + {"spranger", spcmd1}, + {"spkeepassxc", spcmd2}, + {"spnmtui", spcmd3}, + {"spmusic", spcmd4}, }; /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { - /* xprop(1): - * WM_CLASS(STRING) = instance, class - * WM_NAME(STRING) = title - */ - /* class instance title tags mask isfloating monitor */ - { "Firefox", NULL, NULL, 1 << 1, 0, -1 }, + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ + /* class instance title tags mask isfloating monitor */ + { NULL, "spterm", NULL, SPTAG(0), 1, -1 }, + { NULL, "spfm", NULL, SPTAG(1), 1, -1 }, + { NULL, "keepassxc", NULL, SPTAG(2), 1, -1 }, + { NULL, "spnmtui", NULL, SPTAG(3), 1, -1 }, + { NULL, "spmusic", NULL, SPTAG(4), 1, -1 }, }; /* layout(s) */ @@ -39,79 +61,82 @@ static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen win static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */ static const Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, }; /* key definitions */ #define MODKEY Mod4Mask /* Mod4 = Hyper key */ #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, 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} }, /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ 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_main, "-sf", col_gray4, NULL }; +static const char *dmenucmd[] = { "dmenu_run", "-np", "-l", "10", "-g", "2", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_main, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "st", NULL }; +static const char *djcmd[] = { "dj.sh", NULL }; static const Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_d, 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, 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, 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_f, setlayout, {.v = &layouts[2]} }, -// { MODKEY, XK_space, setlayout, {0} }, - { MODKEY, 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 } }, - 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_e, quit, {0} }, + /* modifier key function argument */ +// essential apps + { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_m, spawn, {.v = djcmd } }, +// window management + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_q, killclient, {0} }, + { MODKEY, XK_space, togglefloating, {0} }, +// focus change (tags and monitors) + //{ 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 } }, +// scratchpads + { MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0 } }, // ephemeral term + { MODKEY|ShiftMask, XK_f, togglescratch, {.ui = 1 } }, // file manager + { MODKEY, XK_p, togglescratch, {.ui = 2 } }, // keepass + { MODKEY, XK_n, togglescratch, {.ui = 3 } }, // nmtui + { MODKEY|ShiftMask, XK_m, togglescratch, {.ui = 4 } }, // music +// tag movement + 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_e, quit, {0} }, }; /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static const Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, view, {0} }, - { ClkTagBar, 0, Button3, toggleview, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button1, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; diff --git a/dwm/config.def.h.rej b/dwm/config.def.h.rej index 7bb4a52..6b8c17e 100644 --- a/dwm/config.def.h.rej +++ b/dwm/config.def.h.rej @@ -1,47 +1,26 @@ --- config.def.h +++ config.def.h -@@ -18,17 +18,33 @@ static const char *colors[][3] = { - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +@@ -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 }, }; -+typedef struct { -+ const char *name; -+ const void *cmd; -+} Sp; -+const char *spcmd1[] = {"st", "-n", "spterm", "-g", "120x34", NULL }; -+const char *spcmd2[] = {"st", "-n", "spfm", "-g", "144x41", "-e", "ranger", NULL }; -+const char *spcmd3[] = {"keepassxc", NULL }; -+static Sp scratchpads[] = { -+ /* name cmd */ -+ {"spterm", spcmd1}, -+ {"spranger", spcmd2}, -+ {"keepassxc", spcmd3}, -+}; -+ - /* tagging */ - static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; -- - static const Rule rules[] = { - /* xprop(1): - * 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 }, -+ { "Gimp", NULL, NULL, 0, 1, -1 }, -+ { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, -+ { NULL, "spterm", NULL, SPTAG(0), 1, -1 }, -+ { NULL, "spfm", NULL, SPTAG(1), 1, -1 }, -+ { NULL, "keepassxc", NULL, SPTAG(2), 0, -1 }, - }; - - /* layout(s) */ -@@ -59,6 +75,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 }; - -+ - static Key keys[] = { - /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + /* key definitions */ +@@ -76,6 +79,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_r, setlayout, {.v = &layouts[3]} }, ++ { MODKEY|ShiftMask, XK_r, setlayout, {.v = &layouts[4]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/dwm/config.h b/dwm/config.h index 4d207bc..7f98dec 100644 --- a/dwm/config.h +++ b/dwm/config.h @@ -51,6 +51,8 @@ static const Rule rules[] = { { NULL, "keepassxc", NULL, SPTAG(2), 1, -1 }, { NULL, "spnmtui", NULL, SPTAG(3), 1, -1 }, { NULL, "spmusic", NULL, SPTAG(4), 1, -1 }, + { "st-256color", NULL, NULL, 1 << 0, 0, -1 }, + { "firefox", NULL, NULL, 1 << 1, 0, -1 }, }; /* layout(s) */ @@ -60,11 +62,14 @@ static const int resizehints = 1; /* 1 means respect size hints in tiled resi static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */ +#include "fibonacci.c" static const Layout layouts[] = { /* symbol arrange function */ + { "[\\]", dwindle }, { "[]=", tile }, /* first entry is default */ { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, + { "[@]", spiral }, }; /* key definitions */ @@ -87,7 +92,7 @@ static const char *djcmd[] = { "dj.sh", NULL }; static const Key keys[] = { /* modifier key function argument */ // essential apps - { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_space, spawn, {.v = dmenucmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_m, spawn, {.v = djcmd } }, // window management @@ -96,17 +101,15 @@ static const Key keys[] = { { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_q, killclient, {0} }, - { MODKEY, XK_space, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_f, togglefloating, {0} }, // focus change (tags and monitors) - //{ 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 } }, // scratchpads { MODKEY|ShiftMask, XK_Return, togglescratch, {.ui = 0 } }, // ephemeral term - { MODKEY|ShiftMask, XK_f, togglescratch, {.ui = 1 } }, // file manager + { MODKEY, XK_f, togglescratch, {.ui = 1 } }, // file manager { MODKEY, XK_p, togglescratch, {.ui = 2 } }, // keepass { MODKEY, XK_n, togglescratch, {.ui = 3 } }, // nmtui { MODKEY|ShiftMask, XK_m, togglescratch, {.ui = 4 } }, // music @@ -120,6 +123,7 @@ static const Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) +// misc { MODKEY|ShiftMask, XK_e, quit, {0} }, }; diff --git a/dwm/fibonacci.c b/dwm/fibonacci.c new file mode 100644 index 0000000..fce0a57 --- /dev/null +++ b/dwm/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); +} diff --git a/dwm/patches/dwm-02-fibonacci.diff b/dwm/patches/dwm-02-fibonacci.diff new file mode 100644 index 0000000..d29416f --- /dev/null +++ b/dwm/patches/dwm-02-fibonacci.diff @@ -0,0 +1,115 @@ +From ec9f55b6005cfa3b025b3d700c61af3ce539d057 Mon Sep 17 00:00:00 2001 +From: Niki Yoshiuchi +Date: Sat, 18 Apr 2020 09:55:26 -0700 +Subject: [PATCH] Adding the fibonacci layout patch + +--- + config.def.h | 5 ++++ + fibonacci.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 71 insertions(+) + create mode 100644 fibonacci.c + +diff --git a/config.def.h b/config.def.h +index 1c0b587..5708487 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 */ +@@ -76,6 +79,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_r, setlayout, {.v = &layouts[3]} }, ++ { MODKEY|ShiftMask, XK_r, 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.20.1 + + diff --git a/st/config.def.h b/st/config.def.h index d550750..026aa6c 100644 --- a/st/config.def.h +++ b/st/config.def.h @@ -94,6 +94,9 @@ char *termname = "st-256color"; */ unsigned int tabspaces = 8; +/* bg opacity */ +float alpha = 0.8; + /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { /* 8 normal colors */ diff --git a/st/config.def.h.orig b/st/config.def.h.orig index 8955483..d550750 100644 --- a/st/config.def.h.orig +++ b/st/config.def.h.orig @@ -202,6 +202,8 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Y, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} }, + { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} }, }; /* diff --git a/st/config.h b/st/config.h index d550750..026aa6c 100644 --- a/st/config.h +++ b/st/config.h @@ -94,6 +94,9 @@ char *termname = "st-256color"; */ unsigned int tabspaces = 8; +/* bg opacity */ +float alpha = 0.8; + /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { /* 8 normal colors */ diff --git a/st/patches/st-05-alpha.diff b/st/patches/st-05-alpha.diff new file mode 100644 index 0000000..d0c48c6 --- /dev/null +++ b/st/patches/st-05-alpha.diff @@ -0,0 +1,130 @@ +diff --git a/config.def.h b/config.def.h +index 2cd740a..019a4e1 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -93,6 +93,9 @@ char *termname = "st-256color"; + */ + unsigned int tabspaces = 8; + ++/* bg opacity */ ++float alpha = 0.8; ++ + /* Terminal colors (16 first used in escape sequence) */ + static const char *colorname[] = { + /* 8 normal colors */ +diff --git a/x.c b/x.c +index d73152b..f32fd6c 100644 +--- a/x.c ++++ b/x.c +@@ -105,6 +105,7 @@ typedef struct { + XSetWindowAttributes attrs; + int scr; + int isfixed; /* is fixed geometry? */ ++ int depth; /* bit depth */ + int l, t; /* left and top offset */ + int gm; /* geometry mask */ + } XWindow; +@@ -752,7 +753,7 @@ xresize(int col, int row) + + XFreePixmap(xw.dpy, xw.buf); + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, +- DefaultDepth(xw.dpy, xw.scr)); ++ xw.depth); + XftDrawChange(xw.draw, xw.buf); + xclear(0, 0, win.w, win.h); + +@@ -812,6 +813,10 @@ xloadcols(void) + else + die("could not allocate color %d\n", i); + } ++ ++ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); ++ dc.col[defaultbg].pixel &= 0x00FFFFFF; ++ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; + loaded = 1; + } + +@@ -842,6 +847,12 @@ xsetcolorname(int x, const char *name) + XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); + dc.col[x] = ncolor; + ++ if (x == defaultbg) { ++ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); ++ dc.col[defaultbg].pixel &= 0x00FFFFFF; ++ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; ++ } ++ + return 0; + } + +@@ -1134,11 +1145,25 @@ xinit(int cols, int rows) + Window parent, root; + pid_t thispid = getpid(); + XColor xmousefg, xmousebg; ++ XWindowAttributes attr; ++ XVisualInfo vis; + + if (!(xw.dpy = XOpenDisplay(NULL))) + die("can't open display\n"); + xw.scr = XDefaultScreen(xw.dpy); +- xw.vis = XDefaultVisual(xw.dpy, xw.scr); ++ ++ root = XRootWindow(xw.dpy, xw.scr); ++ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) ++ parent = root; ++ ++ if (XMatchVisualInfo(xw.dpy, xw.scr, 32, TrueColor, &vis) != 0) { ++ xw.vis = vis.visual; ++ xw.depth = vis.depth; ++ } else { ++ XGetWindowAttributes(xw.dpy, parent, &attr); ++ xw.vis = attr.visual; ++ xw.depth = attr.depth; ++ } + + /* font */ + if (!FcInit()) +@@ -1148,7 +1173,7 @@ xinit(int cols, int rows) + xloadfonts(usedfont, 0); + + /* colors */ +- xw.cmap = XDefaultColormap(xw.dpy, xw.scr); ++ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); + xloadcols(); + + /* adjust fixed window geometry */ +@@ -1168,11 +1193,8 @@ xinit(int cols, int rows) + | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; + xw.attrs.colormap = xw.cmap; + +- root = XRootWindow(xw.dpy, xw.scr); +- if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) +- parent = root; +- xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t, +- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, ++ xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, ++ win.w, win.h, 0, xw.depth, InputOutput, + xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity + | CWEventMask | CWColormap, &xw.attrs); + if (parent != root) +@@ -1183,7 +1205,7 @@ xinit(int cols, int rows) + dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures, + &gcvalues); + xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, +- DefaultDepth(xw.dpy, xw.scr)); ++ xw.depth); + XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); + +@@ -2047,6 +2069,10 @@ main(int argc, char *argv[]) + case 'a': + allowaltscreen = 0; + break; ++ case 'A': ++ alpha = strtof(EARGF(usage()), NULL); ++ LIMIT(alpha, 0.0, 1.0); ++ break; + case 'c': + opt_class = EARGF(usage()); + break; + diff --git a/st/x.c b/st/x.c index fe54ce6..e790968 100644 --- a/st/x.c +++ b/st/x.c @@ -108,6 +108,7 @@ typedef struct { XSetWindowAttributes attrs; int scr; int isfixed; /* is fixed geometry? */ + int depth; /* bit depth */ int l, t; /* left and top offset */ int gm; /* geometry mask */ } XWindow; @@ -759,7 +760,7 @@ xresize(int col, int row) XFreePixmap(xw.dpy, xw.buf); xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, - DefaultDepth(xw.dpy, xw.scr)); + xw.depth); XftDrawChange(xw.draw, xw.buf); xclear(0, 0, win.w, win.h); @@ -819,6 +820,10 @@ xloadcols(void) else die("could not allocate color %d\n", i); } + + dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); + dc.col[defaultbg].pixel &= 0x00FFFFFF; + dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; loaded = 1; } @@ -849,6 +854,12 @@ xsetcolorname(int x, const char *name) XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); dc.col[x] = ncolor; + if (x == defaultbg) { + dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); + dc.col[defaultbg].pixel &= 0x00FFFFFF; + dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; + } + return 0; } @@ -1141,11 +1152,25 @@ xinit(int cols, int rows) Window parent, root; pid_t thispid = getpid(); XColor xmousefg, xmousebg; + XWindowAttributes attr; + XVisualInfo vis; if (!(xw.dpy = XOpenDisplay(NULL))) die("can't open display\n"); xw.scr = XDefaultScreen(xw.dpy); - xw.vis = XDefaultVisual(xw.dpy, xw.scr); + + root = XRootWindow(xw.dpy, xw.scr); + if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) + parent = root; + + if (XMatchVisualInfo(xw.dpy, xw.scr, 32, TrueColor, &vis) != 0) { + xw.vis = vis.visual; + xw.depth = vis.depth; + } else { + XGetWindowAttributes(xw.dpy, parent, &attr); + xw.vis = attr.visual; + xw.depth = attr.depth; + } /* font */ if (!FcInit()) @@ -1155,7 +1180,7 @@ xinit(int cols, int rows) xloadfonts(usedfont, 0); /* colors */ - xw.cmap = XDefaultColormap(xw.dpy, xw.scr); + xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); xloadcols(); /* adjust fixed window geometry */ @@ -1175,11 +1200,8 @@ xinit(int cols, int rows) | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; xw.attrs.colormap = xw.cmap; - root = XRootWindow(xw.dpy, xw.scr); - if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) - parent = root; - xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t, - win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, + xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, + win.w, win.h, 0, xw.depth, InputOutput, xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap, &xw.attrs); if (parent != root) @@ -1190,7 +1212,7 @@ xinit(int cols, int rows) dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures, &gcvalues); xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, - DefaultDepth(xw.dpy, xw.scr)); + xw.depth); XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); @@ -2054,6 +2076,10 @@ main(int argc, char *argv[]) case 'a': allowaltscreen = 0; break; + case 'A': + alpha = strtof(EARGF(usage()), NULL); + LIMIT(alpha, 0.0, 1.0); + break; case 'c': opt_class = EARGF(usage()); break; diff --git a/st/x.c.orig b/st/x.c.orig index 4c68714..fe54ce6 100644 --- a/st/x.c.orig +++ b/st/x.c.orig @@ -59,6 +59,8 @@ static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); static void ttysend(const Arg *); +void kscrollup(const Arg *); +void kscrolldown(const Arg *); /* config.h for applying patches and the configuration. */ #include "config.h" @@ -687,6 +689,7 @@ setsel(char *str, Time t) XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) selclear(); + clipcopy(NULL); } void