| dwm-cyclelayouts-20180524-6.2.diff - sites - public wiki contents of suckless.o… | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| dwm-cyclelayouts-20180524-6.2.diff (2897B) | |
| --- | |
| 1 From a09e766a4342f580582082a92b2de65f33208eb4 Mon Sep 17 00:00:00 2001 | |
| 2 From: Christopher Drelich <[email protected]> | |
| 3 Date: Thu, 24 May 2018 00:56:56 -0400 | |
| 4 Subject: [PATCH] Function to cycle through available layouts. | |
| 5 | |
| 6 MOD-CTRL-, and MOD-CTRL-. | |
| 7 cycle backwards and forwards through available layouts. | |
| 8 Probably only useful if you have a lot of additional layouts. | |
| 9 The NULL, NULL layout should always be the last layout in your list, | |
| 10 in order to guarantee consistent behavior. | |
| 11 --- | |
| 12 config.def.h | 3 +++ | |
| 13 dwm.1 | 6 ++++++ | |
| 14 dwm.c | 18 ++++++++++++++++++ | |
| 15 3 files changed, 27 insertions(+) | |
| 16 | |
| 17 diff --git a/config.def.h b/config.def.h | |
| 18 index a9ac303..153b880 100644 | |
| 19 --- a/config.def.h | |
| 20 +++ b/config.def.h | |
| 21 @@ -41,6 +41,7 @@ static const Layout layouts[] = { | |
| 22 { "[]=", tile }, /* first entry is default */ | |
| 23 { "><>", NULL }, /* no layout function means floating b… | |
| 24 { "[M]", monocle }, | |
| 25 + { NULL, NULL }, | |
| 26 }; | |
| 27 | |
| 28 /* key definitions */ | |
| 29 @@ -76,6 +77,8 @@ static Key keys[] = { | |
| 30 { MODKEY, XK_t, setlayout, {.v … | |
| 31 { MODKEY, XK_f, setlayout, {.v … | |
| 32 { MODKEY, XK_m, setlayout, {.v … | |
| 33 + { MODKEY|ControlMask, XK_comma, cyclelayout, … | |
| 34 + { MODKEY|ControlMask, XK_period, cyclelayout, {.i … | |
| 35 { MODKEY, XK_space, setlayout, {0} … | |
| 36 { MODKEY|ShiftMask, XK_space, togglefloating, {0} … | |
| 37 { MODKEY, XK_0, view, {.ui… | |
| 38 diff --git a/dwm.1 b/dwm.1 | |
| 39 index 13b3729..165891b 100644 | |
| 40 --- a/dwm.1 | |
| 41 +++ b/dwm.1 | |
| 42 @@ -92,6 +92,12 @@ Sets monocle layout. | |
| 43 .B Mod1\-space | |
| 44 Toggles between current and previous layout. | |
| 45 .TP | |
| 46 +.B Mod1\-Control\-, | |
| 47 +Cycles backwards in layout list. | |
| 48 +.TP | |
| 49 +.B Mod1\-Control\-. | |
| 50 +Cycles forwards in layout list. | |
| 51 +.TP | |
| 52 .B Mod1\-j | |
| 53 Focus next window. | |
| 54 .TP | |
| 55 diff --git a/dwm.c b/dwm.c | |
| 56 index bb95e26..db73000 100644 | |
| 57 --- a/dwm.c | |
| 58 +++ b/dwm.c | |
| 59 @@ -157,6 +157,7 @@ static void configure(Client *c); | |
| 60 static void configurenotify(XEvent *e); | |
| 61 static void configurerequest(XEvent *e); | |
| 62 static Monitor *createmon(void); | |
| 63 +static void cyclelayout(const Arg *arg); | |
| 64 static void destroynotify(XEvent *e); | |
| 65 static void detach(Client *c); | |
| 66 static void detachstack(Client *c); | |
| 67 @@ -645,6 +646,23 @@ createmon(void) | |
| 68 } | |
| 69 | |
| 70 void | |
| 71 +cyclelayout(const Arg *arg) { | |
| 72 + Layout *l; | |
| 73 + for(l = (Layout *)layouts; l != selmon->lt[selmon->sellt]; l++); | |
| 74 + if(arg->i > 0) { | |
| 75 + if(l->symbol && (l + 1)->symbol) | |
| 76 + setlayout(&((Arg) { .v = (l + 1) })); | |
| 77 + else | |
| 78 + setlayout(&((Arg) { .v = layouts })); | |
| 79 + } else { | |
| 80 + if(l != layouts && (l - 1)->symbol) | |
| 81 + setlayout(&((Arg) { .v = (l - 1) })); | |
| 82 + else | |
| 83 + setlayout(&((Arg) { .v = &layouts[LENGTH(layout… | |
| 84 + } | |
| 85 +} | |
| 86 + | |
| 87 +void | |
| 88 destroynotify(XEvent *e) | |
| 89 { | |
| 90 Client *c; | |
| 91 -- | |
| 92 2.7.4 | |
| 93 |