From 0178a6a766977d5af90355ec202bf7a660bc5517 Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Thu, 2 Sep 2021 16:42:09 +0200 Subject: [PATCH] switchtotag patch to dwm. --- _suckless/dwm/config.def.h | 10 ++-- _suckless/dwm/config.h | 21 ++++--- _suckless/dwm/dwm.c | 21 +++++-- .../dwm/patches/10-dwm-switchtotag-6.2.diff | 58 +++++++++++++++++++ 4 files changed, 89 insertions(+), 21 deletions(-) create mode 100644 _suckless/dwm/patches/10-dwm-switchtotag-6.2.diff diff --git a/_suckless/dwm/config.def.h b/_suckless/dwm/config.def.h index a0faa61..1a56d45 100644 --- a/_suckless/dwm/config.def.h +++ b/_suckless/dwm/config.def.h @@ -48,11 +48,11 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating isterminal noswallow monitor */ - { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, - { "St", NULL, NULL, 0, 0, 1, 0, -1 }, - { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ + /* class instance title tags mask switchtotag isfloating isterminal noswallow monitor */ + { "Gimp", NULL, NULL, 0, 1, 1, 0, 0, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1, -1 }, + { "St", NULL, NULL, 0, 0, 1, 0, -1 }, + { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ { NULL, "spterm", NULL, SPTAG(0), 1, -1 }, { NULL, "spfm", NULL, SPTAG(1), 1, -1 }, { NULL, "keepassxc", NULL, SPTAG(2), 0, -1 }, diff --git a/_suckless/dwm/config.h b/_suckless/dwm/config.h index ddd0e30..02bc4a7 100644 --- a/_suckless/dwm/config.h +++ b/_suckless/dwm/config.h @@ -44,17 +44,16 @@ static const Rule rules[] = { * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating isterminal noswallow monitor */ - { NULL, NULL, "st", 0, 0, 1, 0, -1 }, - { "Firefox", NULL, NULL, 2, 0, 0, 0, -1 }, - { "Ferdi" , NULL, NULL, 1 << 2, 0, 0, 0, -1 }, - { NULL, "mutt", NULL, 1 << 3, 0, 1, 1, -1 }, - { NULL, "nnn", NULL, 1 << 4, 0, 1, 1, -1 }, - { NULL, NULL, "Citrix Workspace", 1 << 8, 0, 0, 0, -1 }, - { "webex", NULL, NULL, 1 << 8, 0, 0, 0, -1 }, - { "Wfica", NULL, NULL, 1 << 9, 0, 0, 0, -1 }, - { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ - { NULL, "spterm", NULL, SPTAG(0), 1, 1, 0, -1 }, + /* class instance title tags mask switchtotag isfloating isterminal noswallow monitor */ + { NULL, NULL, "st", 0, 0, 0, 1, 0, -1 }, + { "Firefox", NULL, NULL, 2, 1, 0, 0, 0, -1 }, + { "Ferdi" , NULL, NULL, 1 << 2, 1, 0, 0, 0, -1 }, + { NULL, "mutt", NULL, 1 << 3, 1, 0, 1, 1, -1 }, + { NULL, "nnn", NULL, 1 << 4, 1, 0, 1, 1, -1 }, + { NULL, NULL, "Citrix Workspace", 1 << 8, 1, 0, 0, 0, -1 }, + { "Wfica", NULL, NULL, 1 << 9, 1, 0, 0, 0, -1 }, + { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */ + { NULL, "spterm", NULL, SPTAG(0), 0, 1, 1, 0, -1 }, }; /* layout(s) */ diff --git a/_suckless/dwm/dwm.c b/_suckless/dwm/dwm.c index 6ebba10..bccd6cf 100644 --- a/_suckless/dwm/dwm.c +++ b/_suckless/dwm/dwm.c @@ -122,6 +122,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; unsigned int tags; + unsigned int switchtotag; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; pid_t pid; Client *next; @@ -171,6 +172,7 @@ typedef struct { const char *instance; const char *title; unsigned int tags; + unsigned int switchtotag; int isfloating; int isterminal; int noswallow; @@ -378,6 +380,11 @@ applyrules(Client *c) for (m = mons; m && m->num != r->monitor; m = m->next); if (m) c->mon = m; + if (r->switchtotag) { + Arg a = { .ui = r->tags }; + c->switchtotag = selmon->tagset[selmon->seltags]; + view(&a); + } } } if (ch.res_class) @@ -2315,11 +2322,15 @@ unmanage(Client *c, int destroyed) } free(c); - if (!s) { - arrange(m); - focus(NULL); - updateclientlist(); - } + if (!s) { + arrange(m); + if (c->switchtotag) { + Arg a = { .ui = c->switchtotag }; + view(&a); + } + focus(NULL); + updateclientlist(); + } } void diff --git a/_suckless/dwm/patches/10-dwm-switchtotag-6.2.diff b/_suckless/dwm/patches/10-dwm-switchtotag-6.2.diff new file mode 100644 index 0000000..453f8ef --- /dev/null +++ b/_suckless/dwm/patches/10-dwm-switchtotag-6.2.diff @@ -0,0 +1,58 @@ +diff -up dwm-6.2-original/config.def.h dwm-6.2-modified/config.def.h +--- dwm-6.2-original/config.def.h 2019-02-02 14:55:28.000000000 +0200 ++++ dwm-6.2-modified/config.def.h 2019-11-18 19:36:22.515566509 +0200 +@@ -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 switchtotag isfloating monitor */ ++ { "Gimp", NULL, NULL, 0, 0, 1, -1 }, ++ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 }, + }; + + /* layout(s) */ +diff -up dwm-6.2-original/dwm.c dwm-6.2-modified/dwm.c +--- dwm-6.2-original/dwm.c 2019-02-02 14:55:28.000000000 +0200 ++++ dwm-6.2-modified/dwm.c 2019-11-18 19:37:18.792187705 +0200 +@@ -92,6 +92,7 @@ struct Client { + int basew, baseh, incw, inch, maxw, maxh, minw, minh; + int bw, oldbw; + unsigned int tags; ++ unsigned int switchtotag; + int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + Client *next; + Client *snext; +@@ -137,6 +138,7 @@ typedef struct { + const char *instance; + const char *title; + unsigned int tags; ++ unsigned int switchtotag; + int isfloating; + int monitor; + } Rule; +@@ -302,6 +304,11 @@ applyrules(Client *c) + for (m = mons; m && m->num != r->monitor; m = m->next); + if (m) + c->mon = m; ++ if (r->switchtotag) { ++ Arg a = { .ui = r->tags }; ++ c->switchtotag = selmon->tagset[selmon->seltags]; ++ view(&a); ++ } + } + } + if (ch.res_class) +@@ -1782,6 +1789,10 @@ unmanage(Client *c, int destroyed) + focus(NULL); + updateclientlist(); + arrange(m); ++ if (c->switchtotag) { ++ Arg a = { .ui = c->switchtotag }; ++ view(&a); ++ } + } + + void