URI:
       update switchtotags patch - sites - public wiki contents of suckless.org
  HTML git clone git://git.suckless.org/sites
   DIR Log
   DIR Files
   DIR Refs
       ---
   DIR commit 427d6b1820dd093ec55dfe8427dc01b6c83d0759
   DIR parent 16d7051833c7870e76ffcc75c2c58897cf628f90
  HTML Author: Niky Kovalski <nikykovalski@gmail.com>
       Date:   Wed, 16 Sep 2026 01:14:48 -0400
       
       update switchtotags patch
       
       This patch had undefined behavior, I have updated the patch to fix this
       as well as removing some functionality that might be unwanted. I have
       also added another version of this patch which restores the exact
       functionality from the original patch.
       
       - rename patch from switchtotag to switchtotags
       - add dwm-switchtotags-20260915-44dbc68.diff file
       - add dwm-switchtotags-restore-20260916-44dbc68.diff file
       - edit index.md
       
       Diffstat:
         M dwm.suckless.org/patches/centeronl… |       4 ++--
         D dwm.suckless.org/patches/switchtot… |      32 -------------------------------
         R dwm.suckless.org/patches/switchtot… |       0 
         A dwm.suckless.org/patches/switchtot… |      79 +++++++++++++++++++++++++++++++
         A dwm.suckless.org/patches/switchtot… |     100 +++++++++++++++++++++++++++++++
         A dwm.suckless.org/patches/switchtot… |      33 +++++++++++++++++++++++++++++++
       
       6 files changed, 214 insertions(+), 34 deletions(-)
       ---
   DIR diff --git a/dwm.suckless.org/patches/centeronlywindow/index.md b/dwm.suckless.org/patches/centeronlywindow/index.md
       @@ -24,6 +24,6 @@ Download
        --------
        * [dwm-centeronlywindow-20260911-44dbc68.diff](dwm-centeronlywindow-20260911-44dbc68.diff)
        
       -Authors
       --------
       +Author
       +------
        Niky Kovalski <nikykovalski@gmail.com>
   DIR diff --git a/dwm.suckless.org/patches/switchtotag/index.md b/dwm.suckless.org/patches/switchtotag/index.md
       @@ -1,32 +0,0 @@
       -switchtotag
       -===========
       -
       -Description
       ------------
       -Adds a rule option to switch to the configured tag when a window opens, then
       -switch back when it closes.
       -
       -The patch modifies `config.def.h`. Make sure to update `config.h` accordingly,
       -if the file exists.
       -
       -Example Configuration
       ----------------------
       -
       -    static const Rule rules[] = {
       -        /* class      instance title tags mask switchtotag isfloating monitor */
       -        { "Gimp",     NULL,    NULL, 0,        0,          1,         -1 },
       -        { "Firefox",  NULL,    NULL, 1 << 8,   1,          0,         -1 },
       -    };
       -
       -In this example, since Firefox is configured to start with tag 9 and switchtotag
       -is enabled, as soon as the application starts, dwm will switch to tag 9. When
       -Firefox closes, dwm will switch back to the tags which were active before the
       -application started.
       -
       -Download
       ---------
       -* [dwm-switchtotag-6.2.diff](dwm-switchtotag-6.2.diff)
       -
       -Author
       -------
       -* rid9 <rid99@protonmail.com>
   DIR diff --git a/dwm.suckless.org/patches/switchtotag/dwm-switchtotag-6.2.diff b/dwm.suckless.org/patches/switchtotags/dwm-switchtotag-6.2.diff
   DIR diff --git a/dwm.suckless.org/patches/switchtotags/dwm-switchtotags-20260915-44dbc68.diff b/dwm.suckless.org/patches/switchtotags/dwm-switchtotags-20260915-44dbc68.diff
       @@ -0,0 +1,79 @@
       +From 587abc8a7b8c22b6de83e64c0679ba15be973b1c Mon Sep 17 00:00:00 2001
       +From: Niky Kovalski <nikykovalski@gmail.com>
       +Date: Tue, 15 Sep 2026 22:47:16 -0400
       +Subject: [PATCH] switchtotags
       +
       +- add switchtotags tags mask field to rule
       +- view switchtotags tags on matching window spawn
       +---
       + config.def.h | 6 +++---
       + dwm.c        | 8 ++++++++
       + 2 files changed, 11 insertions(+), 3 deletions(-)
       +
       +diff --git a/config.def.h b/config.def.h
       +index 81c3fc0..c2cb5c1 100644
       +--- a/config.def.h
       ++++ b/config.def.h
       +@@ -26,9 +26,9 @@ static const Rule rules[] = {
       +          *        WM_CLASS(STRING) = instance, class
       +          *        WM_NAME(STRING) = title
       +          */
       +-        /* class      instance    title       tags mask     isfloating   monitor */
       +-        { "Gimp",     NULL,       NULL,       0,            1,           -1 },
       +-        { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
       ++        /* class      instance    title       tags mask     switchtotags   isfloating   monitor */
       ++        { "Gimp",     NULL,       NULL,       0,            0,             1,           -1 },
       ++        { "Firefox",  NULL,       NULL,       1 << 8,       1 << 8,        0,           -1 },
       + };
       + 
       + /* layout(s) */
       +diff --git a/dwm.c b/dwm.c
       +index ab3a84c..801c597 100644
       +--- a/dwm.c
       ++++ b/dwm.c
       +@@ -91,6 +91,7 @@ struct Client {
       +         int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
       +         int bw, oldbw;
       +         unsigned int tags;
       ++    unsigned int switchtotags;
       +         int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
       +         Client *next;
       +         Client *snext;
       +@@ -136,6 +137,7 @@ typedef struct {
       +         const char *instance;
       +         const char *title;
       +         unsigned int tags;
       ++    unsigned int switchtotags;
       +         int isfloating;
       +         int monitor;
       + } Rule;
       +@@ -286,6 +288,7 @@ applyrules(Client *c)
       +         /* rule matching */
       +         c->isfloating = 0;
       +         c->tags = 0;
       ++    c->switchtotags = 0;
       +         XGetClassHint(dpy, c->win, &ch);
       +         class    = ch.res_class ? ch.res_class : broken;
       +         instance = ch.res_name  ? ch.res_name  : broken;
       +@@ -298,6 +301,7 @@ applyrules(Client *c)
       +                 {
       +                         c->isfloating = r->isfloating;
       +                         c->tags |= r->tags;
       ++            c->switchtotags |= r->switchtotags;
       +                         for (m = mons; m && m->num != r->monitor; m = m->next);
       +                         if (m)
       +                                 c->mon = m;
       +@@ -308,6 +312,10 @@ applyrules(Client *c)
       +         if (ch.res_name)
       +                 XFree(ch.res_name);
       +         c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
       ++    if (c->switchtotags) {
       ++        Arg a = { .ui = c->switchtotags };
       ++        view(&a);
       ++    }
       + }
       + 
       + int
       +-- 
       +2.55.0
       +
   DIR diff --git a/dwm.suckless.org/patches/switchtotags/dwm-switchtotags-restore-20260916-44dbc68.diff b/dwm.suckless.org/patches/switchtotags/dwm-switchtotags-restore-20260916-44dbc68.diff
       @@ -0,0 +1,100 @@
       +From 01d09fa321fc9c5c411e8198a4a9799456001048 Mon Sep 17 00:00:00 2001
       +From: Niky Kovalski <nikykovalski@gmail.com>
       +Date: Wed, 16 Sep 2026 00:22:25 -0400
       +Subject: [PATCH] switchtotags-restore
       +
       +- add switchtotags tags mask field to rule
       +- view switchtotags tags on matching window spawn
       +- save and restore viewed tags on window kill
       +---
       + config.def.h |  6 +++---
       + dwm.c        | 14 ++++++++++++++
       + 2 files changed, 17 insertions(+), 3 deletions(-)
       +
       +diff --git a/config.def.h b/config.def.h
       +index 81c3fc0..c2cb5c1 100644
       +--- a/config.def.h
       ++++ b/config.def.h
       +@@ -26,9 +26,9 @@ static const Rule rules[] = {
       +          *        WM_CLASS(STRING) = instance, class
       +          *        WM_NAME(STRING) = title
       +          */
       +-        /* class      instance    title       tags mask     isfloating   monitor */
       +-        { "Gimp",     NULL,       NULL,       0,            1,           -1 },
       +-        { "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 },
       ++        /* class      instance    title       tags mask     switchtotags   isfloating   monitor */
       ++        { "Gimp",     NULL,       NULL,       0,            0,             1,           -1 },
       ++        { "Firefox",  NULL,       NULL,       1 << 8,       1 << 8,        0,           -1 },
       + };
       + 
       + /* layout(s) */
       +diff --git a/dwm.c b/dwm.c
       +index ab3a84c..071922a 100644
       +--- a/dwm.c
       ++++ b/dwm.c
       +@@ -91,6 +91,7 @@ struct Client {
       +         int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
       +         int bw, oldbw;
       +         unsigned int tags;
       ++    unsigned int switchtotags;
       +         int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
       +         Client *next;
       +         Client *snext;
       +@@ -136,6 +137,7 @@ typedef struct {
       +         const char *instance;
       +         const char *title;
       +         unsigned int tags;
       ++    unsigned int switchtotags;
       +         int isfloating;
       +         int monitor;
       + } Rule;
       +@@ -286,6 +288,7 @@ applyrules(Client *c)
       +         /* rule matching */
       +         c->isfloating = 0;
       +         c->tags = 0;
       ++    c->switchtotags = 0;
       +         XGetClassHint(dpy, c->win, &ch);
       +         class    = ch.res_class ? ch.res_class : broken;
       +         instance = ch.res_name  ? ch.res_name  : broken;
       +@@ -298,6 +301,7 @@ applyrules(Client *c)
       +                 {
       +                         c->isfloating = r->isfloating;
       +                         c->tags |= r->tags;
       ++            c->switchtotags |= r->switchtotags;
       +                         for (m = mons; m && m->num != r->monitor; m = m->next);
       +                         if (m)
       +                                 c->mon = m;
       +@@ -308,6 +312,11 @@ applyrules(Client *c)
       +         if (ch.res_name)
       +                 XFree(ch.res_name);
       +         c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
       ++    if (c->switchtotags) {
       ++        Arg a = { .ui = c->switchtotags };
       ++        c->switchtotags = selmon->tagset[selmon->seltags];
       ++        view(&a);
       ++    }
       + }
       + 
       + int
       +@@ -1780,6 +1789,7 @@ unmanage(Client *c, int destroyed)
       + {
       +         Monitor *m = c->mon;
       +         XWindowChanges wc;
       ++    unsigned int switchtotags = c->switchtotags;
       + 
       +         detach(c);
       +         detachstack(c);
       +@@ -1799,6 +1809,10 @@ unmanage(Client *c, int destroyed)
       +         focus(NULL);
       +         updateclientlist();
       +         arrange(m);
       ++    if (switchtotags) {
       ++        Arg a = { .ui = switchtotags };
       ++        view(&a);
       ++    }
       + }
       + 
       + void
       +-- 
       +2.55.0
       +
   DIR diff --git a/dwm.suckless.org/patches/switchtotags/index.md b/dwm.suckless.org/patches/switchtotags/index.md
       @@ -0,0 +1,33 @@
       +switchtotags
       +============
       +
       +Description
       +-----------
       +This patch adds a rule which views the provided tags when a window
       +is opened.
       +
       +switchtotags-restore
       +--------------------
       +
       +This patch variant restores the tags from the moment a window was
       +opened when the window is closed.
       +
       +Configuration
       +-------------
       +
       +    static const Rule rules[] = {
       +        /* class      instance title tags mask switchtotags isfloating monitor */
       +        { "Gimp",     NULL,    NULL, 0,        0,           1,         -1 },
       +        { "Firefox",  NULL,    NULL, 1 << 8,   1 << 8,      0,         -1 },
       +    };
       +
       +Download
       +--------
       +* [dwm-switchtotag-6.2.diff](dwm-switchtotag-6.2.diff)
       +* [dwm-switchtotags-20260915-44dbc68.diff](dwm-switchtotags-20260915-44dbc68.diff)
       +* [dwm-switchtotags-restore-20260916-44dbc68.diff](dwm-switchtotags-restore-20260916-44dbc68.diff)
       +
       +Authors
       +-------
       +* Niky Kovalski <nikykovalski@gmail.com>
       +* rid9 <rid99@protonmail.com>