[wiki] [sites] [dwm][patch][toggleallmons] Add patch || Philip Thomas Kanianthara
commit f54efcf561dd526ac3b3e31f25ff46dc32c78904
Author: Philip Thomas Kanianthara <philip.kanianthara_AT_gmail.com>
Date: Thu Mar 14 10:04:26 2024 +0800
[dwm][patch][toggleallmons] Add patch
diff --git a/dwm.suckless.org/patches/toggleallmons/dwm-toggleallmons-6.4.diff b/dwm.suckless.org/patches/toggleallmons/dwm-toggleallmons-6.4.diff
new file mode 100644
index 00000000..6d76bd86
--- /dev/null
+++ b/dwm.suckless.org/patches/toggleallmons/dwm-toggleallmons-6.4.diff
_AT_@ -0,0 +1,46 @@
+diff --git a/config.def.h b/config.def.h
+index 061ad66..d702080 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -72,6 +72,7 @@ static const Key keys[] = {
+ { MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY, XK_Return, zoom, {0} },
+ { MODKEY, XK_Tab, view, {0} },
++ { MODKEY|ShiftMask, XK_Tab, toggleall, {0} },
+ { MODKEY|ShiftMask, XK_c, killclient, {0} },
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+ { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
+diff --git a/dwm.c b/dwm.c
+index e5efb6a..f01009f 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -210,6 +210,7 @@ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
++static void toggleall(const Arg *arg);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+_AT_@ -1694,6 +1695,21 @@ tile(Monitor *m)
+ }
+ }
+
++void
++toggleall(const Arg *arg)
++{
++ Monitor* m;
++ for(m = mons; m; m = m->next){
++ if ((arg->ui & TAGMASK) == m->tagset[m->seltags])
++ return;
++ m->seltags ^= 1; /* toggle sel tagset */
++ if (arg->ui & TAGMASK)
++ m->tagset[m->seltags] = arg->ui & TAGMASK;
++ focus(NULL);
++ arrange(m);
++ }
++}
++
+ void
+ togglebar(const Arg *arg)
+ {
diff --git a/dwm.suckless.org/patches/toggleallmons/dwm-toggleallmonspertag-6.4.diff b/dwm.suckless.org/patches/toggleallmons/dwm-toggleallmonspertag-6.4.diff
new file mode 100644
index 00000000..32527f69
--- /dev/null
+++ b/dwm.suckless.org/patches/toggleallmons/dwm-toggleallmonspertag-6.4.diff
_AT_@ -0,0 +1,74 @@
+diff --git a/config.def.h b/config.def.h
+index 061ad66..67afc6d 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -71,6 +71,7 @@ static const Key keys[] = {
+ { MODKEY, XK_h, setmfact, {.f = -0.05} },
+ { MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY, XK_Return, zoom, {0} },
++ { MODKEY|ShiftMask, XK_Tab, toggleall, {0} },
+ { MODKEY, XK_Tab, view, {0} },
+ { MODKEY|ShiftMask, XK_c, killclient, {0} },
+ { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
+diff --git a/dwm.c b/dwm.c
+index e5efb6a..62f711b 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -210,6 +210,7 @@ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
++static void toggleall(const Arg *arg);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+_AT_@ -1694,6 +1695,49 @@ tile(Monitor *m)
+ }
+ }
+
++
++void
++toggleall(const Arg *arg)
++{
++ int i;
++ unsigned int tmptag;
++
++ Monitor* m;
++ for(m = mons; m; m = m->next){
++
++ if ((arg->ui & TAGMASK) == m->tagset[m->seltags])
++ return;
++ m->seltags ^= 1; /* toggle sel tagset */
++ if (arg->ui & TAGMASK) {
++ m->tagset[m->seltags] = arg->ui & TAGMASK;
++ m->pertag->prevtag = m->pertag->curtag;
++
++ if (arg->ui == ~0)
++ m->pertag->curtag = 0;
++ else {
++ for (i = 0; !(arg->ui & 1 << i); i++) ;
++ m->pertag->curtag = i + 1;
++ }
++ } else {
++ tmptag = m->pertag->prevtag;
++ m->pertag->prevtag = m->pertag->curtag;
++ m->pertag->curtag = tmptag;
++ }
++
++ m->nmaster = m->pertag->nmasters[m->pertag->curtag];
++ m->mfact = m->pertag->mfacts[m->pertag->curtag];
++ m->sellt = m->pertag->sellts[m->pertag->curtag];
++ m->lt[m->sellt] = m->pertag->ltidxs[m->pertag->curtag][m->sellt];
++ m->lt[m->sellt^1] = m->pertag->ltidxs[m->pertag->curtag][m->sellt^1];
++
++ if (m->showbar != m->pertag->showbars[m->pertag->curtag])
++ togglebar(NULL);
++
++ focus(NULL);
++ arrange(m);
++ }
++}
++
+ void
+ togglebar(const Arg *arg)
+ {
diff --git a/dwm.suckless.org/patches/toggleallmons/index.md b/dwm.suckless.org/patches/toggleallmons/index.md
new file mode 100644
index 00000000..fe58525e
--- /dev/null
+++ b/dwm.suckless.org/patches/toggleallmons/index.md
_AT_@ -0,0 +1,22 @@
+toggleallmons
+====================
+
+Description
+-----------
+This patch provides a keybinding to toggle the tagsets for all of your monitors at the same time.
+
+Press MOD + Shift + Tab to toggle tagsets for all monitors.
+
+This patch works by creating a new function that wraps the meat of the `view` function in a for loop that iterates through all the monitors, while changing all instances of `selmon` to the name of the iterating variable.
+
+There are two patches provided, one for the base 6.4 release, and one for those who want to use pertag in conjuction.
+Note that to use the pertag variant, you must already have applied the pertag patch.
+
+Download
+--------
+* [dwm-toggleallmons-6.4.diff](dwm-toggleallmons-6.4.diff) - 2024-03-14
+* [dwm-toggleallmonspertag-6.4.diff](dwm-toggleallmonspertag-6.4.diff) - 2024-03-14
+
+Author
+------
+* Philip Thomas K. - <philtomk_AT_gmail.com>
Received on Thu Mar 14 2024 - 03:09:30 CET
This archive was generated by hypermail 2.3.0
: Thu Mar 14 2024 - 03:12:52 CET