diff --git a/config.def.h b/config.def.h index 2c8f184..92b9f44 100644 --- a/config.def.h +++ b/config.def.h @@ -49,6 +49,7 @@ static const Layout layouts[] = { { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, { "|||", col }, + { NULL, NULL }, }; /* key definitions */ @@ -87,6 +88,8 @@ static const Key keys[] = { { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_c, setlayout, {.v = &layouts[3]} }, + { MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } }, + { MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } }, { MODKEY|ShiftMask, XK_f, fullscreen, {0} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, diff --git a/dwm.1 b/dwm.1 index ddc8321..829047b 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 500c71b..276072a 100644 --- a/dwm.c +++ b/dwm.c @@ -196,6 +196,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); @@ -832,6 +833,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) {