commit a83bc0e23244ee155393ad870a1cb53b58644bb9
parent f318176cc472f0bff3e73d8a97bffe073a9ed028
Author: Sam <tritoke@protonmail.com>
Date: Fri, 23 Jul 2021 19:55:11 +0100
Added rotatetags patch.
I've added my rotatetags patch and a page for it, allowing users to add
keybinds to rotate the tagset left and right.
Diffstat:
3 files changed, 187 insertions(+), 0 deletions(-)
diff --git a/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-20210723-cb3f58a.diff b/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-20210723-cb3f58a.diff
@@ -0,0 +1,77 @@
+From 7600ab7f23e732062ce5ff34a42ca0f1ce019702 Mon Sep 17 00:00:00 2001
+From: Sam <tritoke@protonmail.com>
+Date: Fri, 23 Jul 2021 18:38:03 +0100
+Subject: [PATCH] Created rotatetags function, and keybinds.
+
+- Added rotatetags function which rotates the tagset left / right the
+given number of tags, including wrapping round the ends if necessary.
+
+- Added keybinds for MOD + left and right arrows, moving the tagset left /
+right respectively.
+---
+ config.def.h | 2 ++
+ dwm.c | 28 ++++++++++++++++++++++++++++
+ 2 files changed, 30 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..2992431 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -84,6 +84,8 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_Left, rotatetags, {.i = -1 } },
++ { MODKEY, XK_Right, rotatetags, {.i = +1 } },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index 4465af1..768166e 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -192,6 +192,7 @@ static void resize(Client *c, int x, int y, int w, int h, int interact);
+ static void resizeclient(Client *c, int x, int y, int w, int h);
+ static void resizemouse(const Arg *arg);
+ static void restack(Monitor *m);
++static void rotatetags(const Arg *arg);
+ static void run(void);
+ static void scan(void);
+ static int sendevent(Client *c, Atom proto);
+@@ -1369,6 +1370,33 @@ restack(Monitor *m)
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ }
+
++void
++rotatetags(const Arg *arg)
++{
++ const int rot = abs(arg->i);
++ const unsigned int tagset = selmon->tagset[selmon->seltags];
++ unsigned int newtagset;
++
++ /* check the direction of the shift */
++ if (arg->i < 0) {
++ /* shift tags right */
++ newtagset = (tagset >> rot) | (tagset << (LENGTH(tags) - rot));
++ } else {
++ /* shift tags left */
++ newtagset = (tagset << rot) | (tagset >> (LENGTH(tags) - rot));
++ }
++
++ /* mask the tag bits */
++ newtagset &= TAGMASK;
++
++ if (newtagset) {
++ selmon->tagset[selmon->seltags] = newtagset;
++ focus(NULL);
++ arrange(selmon);
++ }
++}
++
++
+ void
+ run(void)
+ {
+--
+2.32.0
+
diff --git a/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-6.2.diff b/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-6.2.diff
@@ -0,0 +1,77 @@
+From 7600ab7f23e732062ce5ff34a42ca0f1ce019702 Mon Sep 17 00:00:00 2001
+From: Sam <tritoke@protonmail.com>
+Date: Fri, 23 Jul 2021 18:38:03 +0100
+Subject: [PATCH] Created rotatetags function, and keybinds.
+
+- Added rotatetags function which rotates the tagset left / right the
+given number of tags, including wrapping round the ends if necessary.
+
+- Added keybinds for MOD + left and right arrows, moving the tagset left /
+right respectively.
+---
+ config.def.h | 2 ++
+ dwm.c | 28 ++++++++++++++++++++++++++++
+ 2 files changed, 30 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..2992431 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -84,6 +84,8 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_Left, rotatetags, {.i = -1 } },
++ { MODKEY, XK_Right, rotatetags, {.i = +1 } },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index 4465af1..768166e 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -192,6 +192,7 @@ static void resize(Client *c, int x, int y, int w, int h, int interact);
+ static void resizeclient(Client *c, int x, int y, int w, int h);
+ static void resizemouse(const Arg *arg);
+ static void restack(Monitor *m);
++static void rotatetags(const Arg *arg);
+ static void run(void);
+ static void scan(void);
+ static int sendevent(Client *c, Atom proto);
+@@ -1369,6 +1370,33 @@ restack(Monitor *m)
+ while (XCheckMaskEvent(dpy, EnterWindowMask, &ev));
+ }
+
++void
++rotatetags(const Arg *arg)
++{
++ const int rot = abs(arg->i);
++ const unsigned int tagset = selmon->tagset[selmon->seltags];
++ unsigned int newtagset;
++
++ /* check the direction of the shift */
++ if (arg->i < 0) {
++ /* shift tags right */
++ newtagset = (tagset >> rot) | (tagset << (LENGTH(tags) - rot));
++ } else {
++ /* shift tags left */
++ newtagset = (tagset << rot) | (tagset >> (LENGTH(tags) - rot));
++ }
++
++ /* mask the tag bits */
++ newtagset &= TAGMASK;
++
++ if (newtagset) {
++ selmon->tagset[selmon->seltags] = newtagset;
++ focus(NULL);
++ arrange(selmon);
++ }
++}
++
++
+ void
+ run(void)
+ {
+--
+2.32.0
+
diff --git a/dwm.suckless.org/patches/rotatetags/index.md b/dwm.suckless.org/patches/rotatetags/index.md
@@ -0,0 +1,33 @@
+rotatetags
+======
+
+Description
+-----------
+This patch provides the ability to rotate the tagset left / right.
+It implements a new function rotatetags which modifies the current tagset.
+It accepts the following values:
+
+* A positive int to rotate the tagset "up", i.e. +1 moves the selection
+ from tag 1 to tag 2.
+
+* A negative int to rotate the tagset "down", i.e. -1 moves the selection
+ from tag 2 to tag 1.
+
+If the tag would be shifted off the end, i.e. rotating tag 9 up, it
+will rotate back to tag 1.
+
+Default key bindings
+--------------------
+ Key Argument Description
+ -----------------------------------
+ Mod-Right +1 Rotate tagset "up".
+ Mod-Left -1 Rotate tagset "down".
+
+Download
+--------
+* [dwm-rotatetags-6.2.diff](dwm-rotatetags-6.2.diff)
+* [dwm-rotatetags-20210723-cb3f58a.diff](dwm-rotatetags-20210723-cb3f58a.diff)
+
+Author
+------
+* Sam Leonard (tritoke) <tritoke@protonmail.com>