diff --git a/config.def.h b/config.def.h index ab6efe2..a922797 100644 --- a/config.def.h +++ b/config.def.h @@ -4,29 +4,31 @@ #include /* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ -static const int showsystray = 1; /* 0 means no systray */ -static const int showbar = 1; /* 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 normbgcolor[] = "#0e0f14"; -static const char normbordercolor[] = "#363b47"; -static const char normfgcolor[] = "#dfdfdf"; -static const char selfgcolor[] = "#eeeeee"; -static const char selbordercolor[] = "#555a63"; -static const char selbgcolor[] = "#282828"; -static const unsigned int baralpha = 0xff; -static const unsigned int borderalpha = OPAQUE; +static const int showsystray = 1; /* 0 means no systray */ +static const int showbar = 1; /* 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 normbgcolor[] = "#0e0f14"; +static const char normbordercolor[] = "#363b47"; +static const char normfgcolor[] = "#dfdfdf"; +static const char selfgcolor[] = "#eeeeee"; +static const char selbordercolor[] = "#555a63"; +static const char selbgcolor[] = "#282828"; +static const unsigned int baralpha = 0xff; +static const unsigned int borderalpha = OPAQUE; + static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, - [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, + [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, }; + static const unsigned int alphas[][3] = { /* fg bg border */ [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, @@ -41,8 +43,8 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask iscentered isfloating monitor */ - { NULL, "origin.exe", NULL, 0, 0, 1, -1 }, + /* class instance title tags mask iscentered isfloating monitor */ + { NULL, "origin.exe", NULL, 0, 0, 1, -1 }, }; /* layout(s) */ @@ -58,15 +60,16 @@ static const Layout layouts[] = { { "B", bstack }, { "B", bstackhoriz }, { "F", NULL }, /* no layout function means floating behavior */ + { NULL, NULL }, }; /* key definitions */ #define MODKEY Mod4Mask #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 } } @@ -76,61 +79,64 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-c", "-l", "20", NULL }; static Key keys[] = { - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Escape, quit, {0} }, - { MODKEY|ShiftMask, XK_b, togglebar, {0} }, - { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, - { MODKEY|ShiftMask, XK_d, togglefloating, {0} }, - { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, - { MODKEY, XK_h, focusstack, {.i = -1 } }, - { MODKEY|ShiftMask, XK_h, zoom, {0} }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY|ShiftMask, XK_j, zoom, {0} }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, - { MODKEY|ShiftMask, XK_k, zoom, {0} }, - { MODKEY, XK_l, focusstack, {.i = +1 } }, - { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[0]} }, - { MODKEY|ShiftMask, XK_o, setmfact, {.f = +0.05} }, - { MODKEY|ShiftMask, XK_q, killclient, {0} }, - { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, - { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} }, - { MODKEY|ShiftMask, XK_v, setlayout, {.v = &layouts[4]} }, - { MODKEY|ShiftMask, XK_z, setmfact, {.f = -0.05} }, - { 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 } }, - //{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1 } }, - //{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1 } }, - //{ MODKEY, XK_space, setlayout, {0} }, - 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) - TAGKEYS( XK_0, 9) + /* modifier key function argument */ + { MODKEY|ShiftMask, XK_Escape, quit, {0} }, + { MODKEY|ShiftMask, XK_b, togglebar, {0} }, + { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_d, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, + { MODKEY, XK_h, focusstack, {.i = -1} }, + { MODKEY|ShiftMask, XK_h, zoom, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1} }, + { MODKEY|ShiftMask, XK_j, zoom, {0} }, + { MODKEY, XK_k, focusstack, {.i = -1} }, + { MODKEY|ShiftMask, XK_k, zoom, {0} }, + { MODKEY, XK_l, focusstack, {.i = +1} }, + { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[0]} }, + { MODKEY|ShiftMask, XK_o, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, + { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} }, + { MODKEY|ShiftMask, XK_v, setlayout, {.v = &layouts[4]} }, + { MODKEY|ShiftMask, XK_z, setmfact, {.f = -0.05} }, + { 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} }, + //{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1} }, + //{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1} }, + //{ MODKEY, XK_space, setlayout, {0} }, + + 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) + TAGKEYS(XK_0, 9) }; /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {.v = 0 } }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} }, - { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} }, - { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} }, - { 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, cyclelayout, {.i = +1} }, + { ClkLtSymbol, 0, Button2, setlayout, {.v = &layouts[0]} }, + { ClkLtSymbol, 0, Button3, cyclelayout, {.i = -1} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} }, + { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} }, + { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} }, + { 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} }, }; diff --git a/config.h b/config.h index ab6efe2..a922797 100644 --- a/config.h +++ b/config.h @@ -4,29 +4,31 @@ #include /* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ -static const int showsystray = 1; /* 0 means no systray */ -static const int showbar = 1; /* 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 normbgcolor[] = "#0e0f14"; -static const char normbordercolor[] = "#363b47"; -static const char normfgcolor[] = "#dfdfdf"; -static const char selfgcolor[] = "#eeeeee"; -static const char selbordercolor[] = "#555a63"; -static const char selbgcolor[] = "#282828"; -static const unsigned int baralpha = 0xff; -static const unsigned int borderalpha = OPAQUE; +static const int showsystray = 1; /* 0 means no systray */ +static const int showbar = 1; /* 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 normbgcolor[] = "#0e0f14"; +static const char normbordercolor[] = "#363b47"; +static const char normfgcolor[] = "#dfdfdf"; +static const char selfgcolor[] = "#eeeeee"; +static const char selbordercolor[] = "#555a63"; +static const char selbgcolor[] = "#282828"; +static const unsigned int baralpha = 0xff; +static const unsigned int borderalpha = OPAQUE; + static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, - [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, + [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, }; + static const unsigned int alphas[][3] = { /* fg bg border */ [SchemeNorm] = { OPAQUE, baralpha, borderalpha }, @@ -41,8 +43,8 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask iscentered isfloating monitor */ - { NULL, "origin.exe", NULL, 0, 0, 1, -1 }, + /* class instance title tags mask iscentered isfloating monitor */ + { NULL, "origin.exe", NULL, 0, 0, 1, -1 }, }; /* layout(s) */ @@ -58,15 +60,16 @@ static const Layout layouts[] = { { "B", bstack }, { "B", bstackhoriz }, { "F", NULL }, /* no layout function means floating behavior */ + { NULL, NULL }, }; /* key definitions */ #define MODKEY Mod4Mask #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 } } @@ -76,61 +79,64 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-c", "-l", "20", NULL }; static Key keys[] = { - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_Escape, quit, {0} }, - { MODKEY|ShiftMask, XK_b, togglebar, {0} }, - { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, - { MODKEY|ShiftMask, XK_d, togglefloating, {0} }, - { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, - { MODKEY, XK_h, focusstack, {.i = -1 } }, - { MODKEY|ShiftMask, XK_h, zoom, {0} }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY|ShiftMask, XK_j, zoom, {0} }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, - { MODKEY|ShiftMask, XK_k, zoom, {0} }, - { MODKEY, XK_l, focusstack, {.i = +1 } }, - { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[0]} }, - { MODKEY|ShiftMask, XK_o, setmfact, {.f = +0.05} }, - { MODKEY|ShiftMask, XK_q, killclient, {0} }, - { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, - { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} }, - { MODKEY|ShiftMask, XK_v, setlayout, {.v = &layouts[4]} }, - { MODKEY|ShiftMask, XK_z, setmfact, {.f = -0.05} }, - { 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 } }, - //{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1 } }, - //{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1 } }, - //{ MODKEY, XK_space, setlayout, {0} }, - 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) - TAGKEYS( XK_0, 9) + /* modifier key function argument */ + { MODKEY|ShiftMask, XK_Escape, quit, {0} }, + { MODKEY|ShiftMask, XK_b, togglebar, {0} }, + { MODKEY|ShiftMask, XK_c, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_d, togglefloating, {0} }, + { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, + { MODKEY, XK_h, focusstack, {.i = -1} }, + { MODKEY|ShiftMask, XK_h, zoom, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1} }, + { MODKEY|ShiftMask, XK_j, zoom, {0} }, + { MODKEY, XK_k, focusstack, {.i = -1} }, + { MODKEY|ShiftMask, XK_k, zoom, {0} }, + { MODKEY, XK_l, focusstack, {.i = +1} }, + { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[0]} }, + { MODKEY|ShiftMask, XK_o, setmfact, {.f = +0.05} }, + { MODKEY|ShiftMask, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[1]} }, + { MODKEY|ShiftMask, XK_u, setlayout, {.v = &layouts[3]} }, + { MODKEY|ShiftMask, XK_v, setlayout, {.v = &layouts[4]} }, + { MODKEY|ShiftMask, XK_z, setmfact, {.f = -0.05} }, + { 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} }, + //{ MODKEY|ShiftMask, XK_o, incnmaster, {.i = +1} }, + //{ MODKEY|ShiftMask, XK_z, incnmaster, {.i = -1} }, + //{ MODKEY, XK_space, setlayout, {0} }, + + 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) + TAGKEYS(XK_0, 9) }; /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {.v = 0 } }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} }, - { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} }, - { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} }, - { 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, cyclelayout, {.i = +1} }, + { ClkLtSymbol, 0, Button2, setlayout, {.v = &layouts[0]} }, + { ClkLtSymbol, 0, Button3, cyclelayout, {.i = -1} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button1, sigdwmblocks, {.i = 1} }, + { ClkStatusText, 0, Button2, sigdwmblocks, {.i = 2} }, + { ClkStatusText, 0, Button3, sigdwmblocks, {.i = 3} }, + { 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} }, }; diff --git a/dwm-cyclelayouts-20180524-6.2.diff b/dwm-cyclelayouts-20180524-6.2.diff new file mode 100644 index 0000000..8079028 --- /dev/null +++ b/dwm-cyclelayouts-20180524-6.2.diff @@ -0,0 +1,93 @@ +From a09e766a4342f580582082a92b2de65f33208eb4 Mon Sep 17 00:00:00 2001 +From: Christopher Drelich +Date: Thu, 24 May 2018 00:56:56 -0400 +Subject: [PATCH] Function to cycle through available layouts. + +MOD-CTRL-, and MOD-CTRL-. +cycle backwards and forwards through available layouts. +Probably only useful if you have a lot of additional layouts. +The NULL, NULL layout should always be the last layout in your list, +in order to guarantee consistent behavior. +--- + config.def.h | 3 +++ + dwm.1 | 6 ++++++ + dwm.c | 18 ++++++++++++++++++ + 3 files changed, 27 insertions(+) + +diff --git a/config.def.h b/config.def.h +index a9ac303..153b880 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -41,6 +41,7 @@ static const Layout layouts[] = { + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { NULL, NULL }, + }; + + /* key definitions */ +@@ -76,6 +77,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|ControlMask, XK_comma, cyclelayout, {.i = -1 } }, ++ { MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, +diff --git a/dwm.1 b/dwm.1 +index 13b3729..165891b 100644 +--- a/dwm.1 ++++ b/dwm.1 +@@ -92,6 +92,12 @@ Sets monocle layout. + .B Mod1\-space + Toggles between current and previous layout. + .TP ++.B Mod1\-Control\-, ++Cycles backwards in layout list. ++.TP ++.B Mod1\-Control\-. ++Cycles forwards in layout list. ++.TP + .B Mod1\-j + Focus next window. + .TP +diff --git a/dwm.c b/dwm.c +index bb95e26..db73000 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -157,6 +157,7 @@ static void configure(Client *c); + static void configurenotify(XEvent *e); + static void configurerequest(XEvent *e); + static Monitor *createmon(void); ++static void cyclelayout(const Arg *arg); + static void destroynotify(XEvent *e); + static void detach(Client *c); + static void detachstack(Client *c); +@@ -645,6 +646,23 @@ createmon(void) + } + + void ++cyclelayout(const Arg *arg) { ++ Layout *l; ++ for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++); ++ if(arg->i > 0) { ++ if(l->symbol && (l + 1)->symbol) ++ setlayout(&((Arg) { .v = (l + 1) })); ++ else ++ setlayout(&((Arg) { .v = layouts })); ++ } else { ++ if(l != layouts && (l - 1)->symbol) ++ setlayout(&((Arg) { .v = (l - 1) })); ++ else ++ setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] })); ++ } ++} ++ ++void + destroynotify(XEvent *e) + { + Client *c; +-- +2.7.4 + diff --git a/dwm.1 b/dwm.1 index 13b3729..165891b 100644 --- a/dwm.1 +++ b/dwm.1 @@ -92,6 +92,12 @@ Sets monocle layout. .B Mod1\-space Toggles between current and previous layout. .TP +.B Mod1\-Control\-, +Cycles backwards in layout list. +.TP +.B Mod1\-Control\-. +Cycles forwards in layout list. +.TP .B Mod1\-j Focus next window. .TP diff --git a/dwm.c b/dwm.c index 2e0a70c..730794f 100644 --- a/dwm.c +++ b/dwm.c @@ -187,6 +187,7 @@ static void configurerequest(XEvent *e); static void copyvalidchars(char *text, char *rawtext); static Monitor *createmon(void); static void deck(Monitor *m); +static void cyclelayout(const Arg *arg); static void destroynotify(XEvent *e); static void detach(Client *c); static void detachstack(Client *c); @@ -809,6 +810,23 @@ createmon(void) return m; } +void +cyclelayout(const Arg *arg) { + Layout *l; + for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++); + if(arg->i > 0) { + if(l->symbol && (l + 1)->symbol) + setlayout(&((Arg) { .v = (l + 1) })); + else + setlayout(&((Arg) { .v = layouts })); + } else { + if(l != layouts && (l - 1)->symbol) + setlayout(&((Arg) { .v = (l - 1) })); + else + setlayout(&((Arg) { .v = &layouts[LENGTH(layouts) - 2] })); + } +} + void destroynotify(XEvent *e) {