[wiki] [sites] Added rotatetags patch. || Sam

From: <git_AT_suckless.org>
Date: Fri, 23 Jul 2021 20:56:21 +0200

commit a83bc0e23244ee155393ad870a1cb53b58644bb9
Author: Sam <tritoke_AT_protonmail.com>
Date: Fri Jul 23 19:55:11 2021 +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.

diff --git a/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-20210723-cb3f58a.diff b/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-20210723-cb3f58a.diff
new file mode 100644
index 00000000..7561f0ab
--- /dev/null
+++ b/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-20210723-cb3f58a.diff
_AT_@ -0,0 +1,77 @@
+From 7600ab7f23e732062ce5ff34a42ca0f1ce019702 Mon Sep 17 00:00:00 2001
+From: Sam <tritoke_AT_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
+_AT_@ -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
+_AT_@ -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);
+_AT_@ -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
new file mode 100644
index 00000000..7561f0ab
--- /dev/null
+++ b/dwm.suckless.org/patches/rotatetags/dwm-rotatetags-6.2.diff
_AT_@ -0,0 +1,77 @@
+From 7600ab7f23e732062ce5ff34a42ca0f1ce019702 Mon Sep 17 00:00:00 2001
+From: Sam <tritoke_AT_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
+_AT_@ -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
+_AT_@ -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);
+_AT_@ -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
new file mode 100644
index 00000000..a61e6058
--- /dev/null
+++ b/dwm.suckless.org/patches/rotatetags/index.md
_AT_@ -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_AT_protonmail.com>
Received on Fri Jul 23 2021 - 20:56:21 CEST

This archive was generated by hypermail 2.3.0 : Fri Jul 23 2021 - 21:00:46 CEST