commit 2637b9acfe5afc88deeb31e2ba7fab59bf1edd43
parent d2ddb7cbb7fd4b0854470bed35381dca13cfead6
Author: Jaye Shovelton <Beanie.github@proton.me>
Date: Sun, 29 Nov 2026 05:05:44 +0000
[dwm][patch][spawnonemptytag] Add option not to switch tags.
I'm calling this a bug fix, no effect on 6.8 but if a user adds their
own bindings that don't spawn windows this would still switch tags.
Diffstat:
2 files changed, 65 insertions(+), 30 deletions(-)
diff --git a/dwm.suckless.org/patches/spawnonemptytag/dwm-spawnonemptytag-6.8.diff b/dwm.suckless.org/patches/spawnonemptytag/dwm-spawnonemptytag-6.8.diff
@@ -1,44 +1,79 @@
-From 0fa0d740bb6507946b4581ac3c52e06e1c3cb29e Mon Sep 17 00:00:00 2001
+From 6ecf97475394209f12607684b384023318a185af Mon Sep 17 00:00:00 2001
From: Jaye Shovelton <Beanie.github@proton.me>
-Date: Sun, 29 Nov 2026 03:51:26 +0000
+Date: Sun, 29 Nov 2026 05:01:44 +0000
Subject: [PATCH] Switch to the closest empty tag upon spawning a command
---
- dwm.c | 21 +++++++++++++++++++++
- 1 file changed, 21 insertions(+)
+ config.def.h | 4 ++--
+ dwm.c | 26 ++++++++++++++++++++++++++
+ 2 files changed, 28 insertions(+), 2 deletions(-)
+diff --git a/config.def.h b/config.def.h
+index 81c3fc0..9022fe0 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -64,7 +64,7 @@ static const char *termcmd[] = { "st", NULL };
+ static const Key keys[] = {
+ /* modifier key function argument */
+ { MODKEY, XK_p, spawn, {.v = dmenucmd } },
+- { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
++ { MODKEY|ShiftMask, XK_Return, spawnwindow, {.v = termcmd } },
+ { MODKEY, XK_b, togglebar, {0} },
+ { MODKEY, XK_j, focusstack, {.i = +1 } },
+ { MODKEY, XK_k, focusstack, {.i = -1 } },
+@@ -105,7 +105,7 @@ static const Button buttons[] = {
+ { ClkLtSymbol, 0, Button1, setlayout, {0} },
+ { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
+ { ClkWinTitle, 0, Button2, zoom, {0} },
+- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
++ { ClkStatusText, 0, Button2, spawnwindow, {.v = termcmd } },
+ { ClkClientWin, MODKEY, Button1, movemouse, {0} },
+ { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
+ { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
diff --git a/dwm.c b/dwm.c
-index 53b393e..346402f 100644
+index 53b393e..30996fc 100644
--- a/dwm.c
+++ b/dwm.c
-@@ -1651,6 +1651,27 @@ spawn(const Arg *arg)
+@@ -205,6 +205,7 @@ static void setup(void);
+ static void seturgent(Client *c, int urg);
+ static void showhide(Client *c);
+ static void spawn(const Arg *arg);
++static void spawnwindow(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *m);
+@@ -1666,6 +1667,31 @@ spawn(const Arg *arg)
+ }
+ }
- if (arg->v == dmenucmd)
- dmenumon[0] = '0' + selmon->num;
-+ else {
-+ unsigned int occ = 0;
-+ unsigned int tagset = selmon->tagset[selmon->seltags];
-+ Arg ct, t;
++void
++spawnwindow(const Arg *arg)
++{
++ unsigned int occ = 0;
++ unsigned int tagset = selmon->tagset[selmon->seltags];
++ Arg ct, t;
+
-+ for(Client *c = selmon->clients; c; c=c->next)
-+ occ |= c->tags == TAGMASK ? 0 : c->tags;
-+ /* get earliest tag in tagset */
-+ ct.ui = tagset & -tagset;
-+ t = ct;
++ for(Client *c = selmon->clients; c; c=c->next)
++ occ |= c->tags == TAGMASK ? 0 : c->tags;
++ /* get earliest tag in tagset */
++ ct.ui = tagset & -tagset;
++ t = ct;
+
-+ while (t.ui & occ) {
-+ unsigned int newt = ((t.ui << 1) & TAGMASK) | (t.ui >> (LENGTH(tags) - 1));
-+ occ ^= t.ui;
-+ t.ui = newt;
-+ }
++ while (t.ui & occ) {
++ unsigned int newt = ((t.ui << 1) & TAGMASK) | (t.ui >> (LENGTH(tags) - 1));
++ occ ^= t.ui;
++ t.ui = newt;
++ }
+
-+ if (t.ui != ct.ui)
++ if (t.ui != ct.ui)
+ view(&t);
-+ }
+
- if (fork() == 0) {
- if (dpy)
- close(ConnectionNumber(dpy));
++ spawn(arg);
++}
++
+ void
+ tag(const Arg *arg)
+ {
--
2.56.1
diff --git a/dwm.suckless.org/patches/spawnonemptytag/index.md b/dwm.suckless.org/patches/spawnonemptytag/index.md
@@ -3,9 +3,9 @@ spawnonemptytag
Description
-----------
-When a binding executes `spawn`, this patch switches to the closest empty tag
-on the right. It wraps round if there are no more tags and does nothing if the
-current tag is empty or there are no empty tags.
+When a binding executes `spawnwindow`, this patch switches to the closest empty
+tag on the right. It wraps round if there are no more tags and does nothing if
+the current tag is empty or there are no empty tags.
Download
--------