sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 9f766b29f7ac9d65384ae70a9b8044af1f0d99a0
parent 13dcce4d1dcfefdb90904dd564147547fe17fe78
Author: Jaye Shovelton <Beanie.github@proton.me>
Date:   Thu,  3 Dec 2026 04:47:58 +0000

[dwm][patch][autoswitchtag] Add a patch to auto-switch to/from empty tags

Encompasses the `spawnonemptytag` patch

Diffstat:
Adwm.suckless.org/patches/autoswitchtag/dwm-autoswitchtag-6.8.diff | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rdwm.suckless.org/patches/spawnonemptytag/dwm-spawnonemptytag-6.8.diff -> dwm.suckless.org/patches/autoswitchtag/dwm-spawnonemptytag-6.8.diff | 0
Rdwm.suckless.org/patches/spawnonemptytag/dwm-spawnonemptytag-spawnwindow-6.8.diff -> dwm.suckless.org/patches/autoswitchtag/dwm-spawnonemptytag-spawnwindow-6.8.diff | 0
Adwm.suckless.org/patches/autoswitchtag/dwm-switchfromemptytag-6.8.diff | 44++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/autoswitchtag/index.md | 24++++++++++++++++++++++++
Ddwm.suckless.org/patches/spawnonemptytag/index.md | 21---------------------
6 files changed, 142 insertions(+), 21 deletions(-)

diff --git a/dwm.suckless.org/patches/autoswitchtag/dwm-autoswitchtag-6.8.diff b/dwm.suckless.org/patches/autoswitchtag/dwm-autoswitchtag-6.8.diff @@ -0,0 +1,74 @@ +From 467bb30189b19f642518425ddcabab38bbbab749 Mon Sep 17 00:00:00 2001 +From: Jaye Shovelton <Beanie.github@proton.me> +Date: Thu, 3 Dec 2026 04:45:21 +0000 +Subject: [PATCH] Auto-switch to/from empty tags when spawning/destroying + windows. + +--- + dwm.c | 36 ++++++++++++++++++++++++++++++++++++ + 1 file changed, 36 insertions(+) + +diff --git a/dwm.c b/dwm.c +index 53b393e..dfd2b77 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -1034,6 +1034,9 @@ manage(Window w, XWindowAttributes *wa) + Client *c, *t = NULL; + Window trans = None; + XWindowChanges wc; ++ unsigned int ts = selmon->tagset[selmon->seltags]; ++ /* get earliest tag in tagset */ ++ Arg ct = { .ui = ts & -ts }, nt; + + c = ecalloc(1, sizeof(Client)); + c->win = w; +@@ -1074,6 +1077,20 @@ manage(Window w, XWindowAttributes *wa) + c->isfloating = c->oldstate = trans != None || c->isfixed; + if (c->isfloating) + XRaiseWindow(dpy, c->win); ++ if (!c->tags) { ++ nt = ct; ++ if (!c->isfloating) { ++ /* switch to the next empty tag */ ++ unsigned int occ = 0; ++ for (Client *ec = c->mon->clients; ec; ec = ec->next) ++ occ |= ec->tags == TAGMASK || ec->isfloating ? 0 : ec->tags; ++ for (; nt.ui & occ; nt.ui = ((nt.ui << 1) & TAGMASK) | (nt.ui >> ++ (LENGTH(tags) - 1))) ++ occ ^= nt.ui; ++ view(&nt); ++ } ++ c->tags = nt.ui; ++ } + attach(c); + attachstack(c); + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, +@@ -1798,6 +1815,25 @@ unmanage(Client *c, int destroyed) + free(c); + focus(NULL); + updateclientlist(); ++ ++ /* switch to the previous full tag */ ++ unsigned int occ = 0; ++ unsigned int empty; ++ unsigned int tagset = selmon->tagset[selmon->seltags]; ++ Arg ctag, tag; ++ for(c = selmon->clients; c; c = c->next) ++ occ |= c->tags == TAGMASK || c->isfloating ? 0 : c->tags; ++ empty = ~occ; ++ ctag.ui = tagset & -tagset; /* get earliest tag in tagset */ ++ tag = ctag; ++ while (tag.ui & empty) { ++ unsigned int newtag = (tag.ui >> 1) | ((tag.ui << (LENGTH(tags) - 1)) & TAGMASK); ++ empty ^= tag.ui; ++ tag.ui = newtag; ++ } ++ if (tag.ui != ctag.ui) ++ view(&tag); ++ + arrange(m); + } + +-- +2.56.1 + diff --git a/dwm.suckless.org/patches/spawnonemptytag/dwm-spawnonemptytag-6.8.diff b/dwm.suckless.org/patches/autoswitchtag/dwm-spawnonemptytag-6.8.diff diff --git a/dwm.suckless.org/patches/spawnonemptytag/dwm-spawnonemptytag-spawnwindow-6.8.diff b/dwm.suckless.org/patches/autoswitchtag/dwm-spawnonemptytag-spawnwindow-6.8.diff diff --git a/dwm.suckless.org/patches/autoswitchtag/dwm-switchfromemptytag-6.8.diff b/dwm.suckless.org/patches/autoswitchtag/dwm-switchfromemptytag-6.8.diff @@ -0,0 +1,44 @@ +From ef57e1dae41c0c1661088dc922c18f31d2fa84d1 Mon Sep 17 00:00:00 2001 +From: Jaye Shovelton <Beanie.github@proton.me> +Date: Mon, 30 Nov 2026 18:50:58 +0000 +Subject: [PATCH] Auto-switch to a previous full tag if current one is empty. + +--- + dwm.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/dwm.c b/dwm.c +index 53b393e..59f247c 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -1798,6 +1798,27 @@ unmanage(Client *c, int destroyed) + free(c); + focus(NULL); + updateclientlist(); ++ ++ /* switch to the previous full tag */ ++ unsigned int occ = 0; ++ unsigned int empty; ++ unsigned int tagset = selmon->tagset[selmon->seltags]; ++ Arg ctag, tag; ++ for(c = selmon->clients; c; c = c->next) ++ occ |= c->tags == TAGMASK || c->isfloating ? 0 : c->tags; ++ empty = ~occ; ++ ctag.ui = tagset & -tagset; /* get earliest tag in tagset */ ++ tag = ctag; ++ while (tag.ui & empty) { ++ unsigned int newtag = (tag.ui >> 1) | ((tag.ui << (LENGTH(tags) - 1)) & TAGMASK); ++ empty ^= tag.ui; ++ tag.ui = newtag; ++ } ++ if (tag.ui != ctag.ui) ++ /* NOTE: this uses selmon instead of c->mon, but it's assumed they're ++ the same */ ++ view(&tag); ++ + arrange(m); + } + +-- +2.56.1 + diff --git a/dwm.suckless.org/patches/autoswitchtag/index.md b/dwm.suckless.org/patches/autoswitchtag/index.md @@ -0,0 +1,24 @@ +autoswitchtag +============= + +Description +----------- +This patch automates switching to a new empty tag on the right when spawning a +window and switching back from an empty tag to the left when destroying the +last window, wrapping to and from the first and last tags. Floating windows are +ignored. + +Download +-------- +* [dwm-autoswitchtag-6.8.diff](dwm-autoswitchtag-6.8.diff) +* [dwm-spawnonemptytag-6.8.diff](dwm-spawnonemptytag-6.8.diff) (only switch + when spawning) +* [dwm-spawnonemptytag-spawnwindow-6.8.diff](dwm-spawnonemptytag-spawnwindow-6.8.diff) + (alternative implementation of `spawnonemptytag` that only switches on + specified commands) +* [dwm-switchfromemptytag-6.8.diff](dwm-switchfromemptytag-6.8.diff) (only + switch when destroying) + +Authors +------- +* Jaye Shovelton - <Beanie.github@proton.me> diff --git a/dwm.suckless.org/patches/spawnonemptytag/index.md b/dwm.suckless.org/patches/spawnonemptytag/index.md @@ -1,21 +0,0 @@ -spawnonemptytag -=============== - -Description ------------ -When a non-floating window is spawned, this patch switches to the closest empty -tag on the right, ignoring floating winows. 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 --------- -* [dwm-spawnonemptytag-6.8.diff](dwm-spawnonemptytag-6.8.diff) - -Alternative implementation that splits `spawn`, allowing control over which -commands trigger switching: - -* [dwm-spawnonemptytag-spawnwindow-6.8.diff](dwm-spawnonemptytag-spawnwindow-6.8.diff) - -Authors -------- -* Jaye Shovelton - <Beanie.github@proton.me>