aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-15 14:10:04 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-15 14:10:04 +0530
commitfc76456244d6bbd1d92b685b6e2c95411757943f (patch)
tree7c4c3130ec689a8355c367d69069a92d7356d883
parentb1684df06c97526e59a7d4a31695cde80bf6b948 (diff)
patched dwm-cyclelayouts-20180524-6.2.diffHEADmaster
-rw-r--r--config.def.h24
-rw-r--r--dwm.16
-rw-r--r--dwm.c18
-rw-r--r--patches/dwm-cyclelayouts-20180524-6.2.diff93
4 files changed, 128 insertions, 13 deletions
diff --git a/config.def.h b/config.def.h
index 425af1c..0cded32 100644
--- a/config.def.h
+++ b/config.def.h
@@ -108,6 +108,10 @@ static const Key keys[] = {
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY|ShiftMask, XK_q, quit, {0} }, // TODO: add confirmation or something
+ /* functions for "all tags" TODO: map them somewhere, they seem useful */
+ // { MODKEY, XK_0, view, {.ui = ~0 } },
+ // { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+
/* viewing and moving to adjacent tags */
{ MODKEY, XK_h, viewtoleft, {0} },
{ MODKEY, XK_l, viewtoright, {0} },
@@ -128,6 +132,12 @@ static const Key keys[] = {
{ MODKEY|ControlMask, XK_Left, movekeyboard_x, {.i = -1}},
{ MODKEY|ControlMask, XK_Right, movekeyboard_x, {.i = 1}},
+ /* layouts */
+ { MODKEY, XK_equal, cyclelayout, {.i = -1 } },
+ { MODKEY, XK_plus, togglefloating, {0} },
+ // { MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
+ // { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+
/* tiling window management */
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
@@ -135,20 +145,8 @@ static const Key keys[] = {
// { MODKEY, XK_r, incnmaster, {.i = +1 } },
// { MODKEY|ShiftMask, XK_r, incnmaster, {.i = -1 } },
// { MODKEY, XK_question, setmfact, {.f = -0.05} },
- // { MODKEY, XK_slash, setmfact, {.f = +0.05} },
+ // { MODKEY, XK_slash, setmfact, {.f = +0.05} },
// { MODKEY, XK_Tab, view, {0} },
-
- /* layouts */
- // TODO: only have toggle floating, default layout, and cycle layout
- //{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
- //{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
- //{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
- //{ MODKEY, XK_space, setlayout, {0} },
- //{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
-
- /* functions for "all tags" TODO: map them somewhere, they seem useful */
- // { MODKEY, XK_0, view, {.ui = ~0 } },
- // { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
};
/* button definitions */
diff --git a/dwm.1 b/dwm.1
index 6d8cd6d..5dfd3c3 100644
--- a/dwm.1
+++ b/dwm.1
@@ -104,6 +104,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 c246d93..45c6ddb 100644
--- a/dwm.c
+++ b/dwm.c
@@ -165,6 +165,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);
@@ -691,6 +692,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;
diff --git a/patches/dwm-cyclelayouts-20180524-6.2.diff b/patches/dwm-cyclelayouts-20180524-6.2.diff
new file mode 100644
index 0000000..8079028
--- /dev/null
+++ b/patches/dwm-cyclelayouts-20180524-6.2.diff
@@ -0,0 +1,93 @@
+From a09e766a4342f580582082a92b2de65f33208eb4 Mon Sep 17 00:00:00 2001
+From: Christopher Drelich <cd@cdrakka.com>
+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
+