[wiki] [sites] [dwm][patch] Add adjacenttag patch || Leo Martin

From: <git_AT_suckless.org>
Date: Sat, 02 Oct 2021 15:48:14 +0200

commit dc7beb318d69bb3fc143cbc42123ca90df0b0ba1
Author: Leo Martin <leomartin05_AT_tutanota.com>
Date: Sat Oct 2 14:48:08 2021 +0100

    [dwm][patch] Add adjacenttag patch

diff --git a/dwm.suckless.org/patches/adjacenttag/dwm-adjacenttag-6.2.diff b/dwm.suckless.org/patches/adjacenttag/dwm-adjacenttag-6.2.diff
new file mode 100644
index 00000000..6121f65e
--- /dev/null
+++ b/dwm.suckless.org/patches/adjacenttag/dwm-adjacenttag-6.2.diff
_AT_@ -0,0 +1,126 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2021-10-02 13:57:18.011307099 +0100
++++ b/config.def.h 2021-10-02 13:58:07.812080253 +0100
+_AT_@ -84,6 +84,10 @@ 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_Right, viewnext, {0} },
++ { MODKEY, XK_Left, viewprev, {0} },
++ { MODKEY|ShiftMask, XK_Right, tagtonext, {0} },
++ { MODKEY|ShiftMask, XK_Left, tagtoprev, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2021-10-02 13:57:18.011307099 +0100
++++ b/dwm.c 2021-10-02 14:21:17.063622953 +0100
+_AT_@ -183,8 +183,10 @@ static void maprequest(XEvent *e);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static unsigned int nexttag(void);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *);
++static unsigned int prevtag(void);
+ static void propertynotify(XEvent *e);
+ static void quit(const Arg *arg);
+ static Monitor *recttomon(int x, int y, int w, int h);
+_AT_@ -208,6 +210,8 @@ static void sigchld(int unused);
+ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
++static void tagtonext(const Arg *arg);
++static void tagtoprev(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+_AT_@ -227,6 +231,8 @@ static void updatetitle(Client *c);
+ static void updatewindowtype(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
++static void viewnext(const Arg *arg);
++static void viewprev(const Arg *arg);
+ static Client *wintoclient(Window w);
+ static Monitor *wintomon(Window w);
+ static int xerror(Display *dpy, XErrorEvent *ee);
+_AT_@ -1192,6 +1198,13 @@ movemouse(const Arg *arg)
+ }
+ }
+
++unsigned int
++nexttag(void)
++{
++ unsigned int seltag = selmon->tagset[selmon->seltags];
++ return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
+_AT_@ -1208,6 +1221,13 @@ pop(Client *c)
+ arrange(c->mon);
+ }
+
++unsigned int
++prevtag(void)
++{
++ unsigned int seltag = selmon->tagset[selmon->seltags];
++ return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
++}
++
+ void
+ propertynotify(XEvent *e)
+ {
+_AT_@ -1671,6 +1691,32 @@ tagmon(const Arg *arg)
+ }
+
+ void
++tagtonext(const Arg *arg)
++{
++ unsigned int tmp;
++
++ if (selmon->sel == NULL)
++ return;
++
++ tmp = nexttag();
++ tag(&(const Arg){.ui = tmp });
++ view(&(const Arg){.ui = tmp });
++}
++
++void
++tagtoprev(const Arg *arg)
++{
++ unsigned int tmp;
++
++ if (selmon->sel == NULL)
++ return;
++
++ tmp = prevtag();
++ tag(&(const Arg){.ui = tmp });
++ view(&(const Arg){.ui = tmp });
++}
++
++void
+ tile(Monitor *m)
+ {
+ unsigned int i, n, h, mw, my, ty;
+_AT_@ -2044,6 +2090,18 @@ view(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++viewnext(const Arg *arg)
++{
++ view(&(const Arg){.ui = nexttag()});
++}
++
++void
++viewprev(const Arg *arg)
++{
++ view(&(const Arg){.ui = prevtag()});
++}
++
+ Client *
+ wintoclient(Window w)
+ {
diff --git a/dwm.suckless.org/patches/adjacenttag/dwm-adjacenttag-skipvacant-6.2.diff b/dwm.suckless.org/patches/adjacenttag/dwm-adjacenttag-skipvacant-6.2.diff
new file mode 100644
index 00000000..6e39d718
--- /dev/null
+++ b/dwm.suckless.org/patches/adjacenttag/dwm-adjacenttag-skipvacant-6.2.diff
_AT_@ -0,0 +1,161 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2021-10-02 14:22:28.034782413 +0100
++++ b/config.def.h 2021-10-02 14:22:28.044723532 +0100
+_AT_@ -84,6 +84,10 @@ 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_Right, viewnext, {0} },
++ { MODKEY, XK_Left, viewprev, {0} },
++ { MODKEY|ShiftMask, XK_Right, tagtonext, {0} },
++ { MODKEY|ShiftMask, XK_Left, tagtoprev, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2021-10-02 14:22:28.034782413 +0100
++++ b/dwm.c 2021-10-02 14:27:54.599845767 +0100
+_AT_@ -183,8 +183,10 @@ static void maprequest(XEvent *e);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static unsigned int nexttag(void);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *);
++static unsigned int prevtag(void);
+ static void propertynotify(XEvent *e);
+ static void quit(const Arg *arg);
+ static Monitor *recttomon(int x, int y, int w, int h);
+_AT_@ -208,6 +210,8 @@ static void sigchld(int unused);
+ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
++static void tagtonext(const Arg *arg);
++static void tagtoprev(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+_AT_@ -227,6 +231,8 @@ static void updatetitle(Client *c);
+ static void updatewindowtype(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
++static void viewnext(const Arg *arg);
++static void viewprev(const Arg *arg);
+ static Client *wintoclient(Window w);
+ static Monitor *wintomon(Window w);
+ static int xerror(Display *dpy, XErrorEvent *ee);
+_AT_@ -1192,6 +1198,29 @@ movemouse(const Arg *arg)
+ }
+ }
+
++unsigned int
++nexttag(void)
++{
++ unsigned int seltag = selmon->tagset[selmon->seltags];
++ unsigned int usedtags = 0;
++ Client *c = selmon->clients;
++
++ if (!c)
++ return seltag;
++
++ /* skip vacant tags */
++ do {
++ usedtags |= c->tags;
++ c = c->next;
++ } while (c);
++
++ do {
++ seltag = seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
++ } while (!(seltag & usedtags));
++
++ return seltag;
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
+_AT_@ -1208,6 +1237,28 @@ pop(Client *c)
+ arrange(c->mon);
+ }
+
++unsigned int
++prevtag(void)
++{
++ unsigned int seltag = selmon->tagset[selmon->seltags];
++ unsigned int usedtags = 0;
++ Client *c = selmon->clients;
++ if (!c)
++ return seltag;
++
++ /* skip vacant tags */
++ do {
++ usedtags |= c->tags;
++ c = c->next;
++ } while (c);
++
++ do {
++ seltag = seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
++ } while (!(seltag & usedtags));
++
++ return seltag;
++}
++
+ void
+ propertynotify(XEvent *e)
+ {
+_AT_@ -1671,6 +1722,36 @@ tagmon(const Arg *arg)
+ }
+
+ void
++tagtonext(const Arg *arg)
++{
++ unsigned int tmp;
++
++ if (selmon->sel == NULL)
++ return;
++
++ if ((tmp = nexttag()) == selmon->tagset[selmon->seltags])
++ return;
++
++ tag(&(const Arg){.ui = tmp });
++ view(&(const Arg){.ui = tmp });
++}
++
++void
++tagtoprev(const Arg *arg)
++{
++ unsigned int tmp;
++
++ if (selmon->sel == NULL)
++ return;
++
++ if ((tmp = prevtag()) == selmon->tagset[selmon->seltags])
++ return;
++
++ tag(&(const Arg){.ui = tmp });
++ view(&(const Arg){.ui = tmp });
++}
++
++void
+ tile(Monitor *m)
+ {
+ unsigned int i, n, h, mw, my, ty;
+_AT_@ -2044,6 +2125,18 @@ view(const Arg *arg)
+ arrange(selmon);
+ }
+
++void
++viewnext(const Arg *arg)
++{
++ view(&(const Arg){.ui = nexttag()});
++}
++
++void
++viewprev(const Arg *arg)
++{
++ view(&(const Arg){.ui = prevtag()});
++}
++
+ Client *
+ wintoclient(Window w)
+ {
diff --git a/dwm.suckless.org/patches/adjacenttag/index.md b/dwm.suckless.org/patches/adjacenttag/index.md
new file mode 100644
index 00000000..b258816c
--- /dev/null
+++ b/dwm.suckless.org/patches/adjacenttag/index.md
_AT_@ -0,0 +1,16 @@
+adjacenttag
+===========
+
+Description
+-----------
+This patch allow to focus on the adjacent tag (left or right) or tag a client
+to it, the version with 'skipvacant' will skip vacant tags
+
+Download
+--------
+* [dwm-adjacenttag-6.2.diff](dwm-adjacenttag-6.2.diff)
+* [dwm-adjacenttag-skipvacant-6.2.diff](dwm-adjacenttag_skipvacant-6.2.diff)
+
+Authors
+-------
+* Ayoub Khater - (ayoub khater at protonmail dot com)
Received on Sat Oct 02 2021 - 15:48:14 CEST

This archive was generated by hypermail 2.3.0 : Sat Oct 02 2021 - 15:48:47 CEST