[wiki] [sites] [dwm][patch][alternativetags] Added momentary switch and update for ed3ab64 || Jack Bird
commit 0333cebb10bb3e8a04fabfe144cd4b19f29705ea
Author: Jack Bird <jack.bird_AT_durham.ac.uk>
Date: Sun Aug 29 17:51:08 2021 +0100
[dwm][patch][alternativetags] Added momentary switch and update for ed3ab64
There is now a config option to only change to the alttags while the keys are
being held down. And the patch can be cleanly applied from ed3ab64 onwards.
diff --git a/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-20210829-ed3ab6b4.diff b/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-20210829-ed3ab6b4.diff
new file mode 100644
index 00000000..a4006730
--- /dev/null
+++ b/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-20210829-ed3ab6b4.diff
_AT_@ -0,0 +1,130 @@
+From 65a6751d45f142760c981ed5fe034dbb640fef63 Mon Sep 17 00:00:00 2001
+From: Jack Bird <jack.bird_AT_durham.ac.uk>
+Date: Sun, 29 Aug 2021 17:17:30 +0100
+Subject: [PATCH] Updated alttags for ed3ab6b4
+
+---
+ config.def.h | 3 +++
+ dwm.c | 35 +++++++++++++++++++++++++++++++++--
+ 2 files changed, 36 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..80df7db 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -20,6 +20,8 @@ static const char *colors[][3] = {
+
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
++static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
++static const int momentaryalttags = 0; /* 1 means alttags will show only when key is held down*/
+
+ static const Rule rules[] = {
+ /* xprop(1):
+_AT_@ -85,6 +87,7 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_n, togglealttag, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index 5e4d494..5312b7e 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -130,6 +130,7 @@ struct Monitor {
+ Monitor *next;
+ Window barwin;
+ const Layout *lt[2];
++ unsigned int alttag;
+ };
+
+ typedef struct {
+_AT_@ -177,6 +178,7 @@ static void grabbuttons(Client *c, int focused);
+ static void grabkeys(void);
+ static void incnmaster(const Arg *arg);
+ static void keypress(XEvent *e);
++static void keyrelease(XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window w, XWindowAttributes *wa);
+ static void mappingnotify(XEvent *e);
+_AT_@ -210,6 +212,7 @@ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
++static void togglealttag();
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+ static void toggletag(const Arg *arg);
+_AT_@ -254,6 +257,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
++ [KeyRelease] = keyrelease,
+ [MappingNotify] = mappingnotify,
+ [MapRequest] = maprequest,
+ [MotionNotify] = motionnotify,
+_AT_@ -696,7 +700,7 @@ dirtomon(int dir)
+ void
+ drawbar(Monitor *m)
+ {
+- int x, w, tw = 0;
++ int x, w, wdelta, tw = 0;
+ int boxs = drw->fonts->h / 9;
+ int boxw = drw->fonts->h / 6 + 2;
+ unsigned int i, occ = 0, urg = 0;
+_AT_@ -717,8 +721,9 @@ drawbar(Monitor *m)
+ x = 0;
+ for (i = 0; i < LENGTH(tags); i++) {
+ w = TEXTW(tags[i]);
++ wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0;
+ drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
++ drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i);
+ if (occ & 1 << i)
+ drw_rect(drw, x + boxs, boxs, boxw, boxw,
+ m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
+_AT_@ -999,6 +1004,25 @@ keypress(XEvent *e)
+ keys[i].func(&(keys[i].arg));
+ }
+
++void
++keyrelease(XEvent *e)
++{
++ unsigned int i;
++ KeySym keysym;
++ XKeyEvent *ev;
++
++ ev = &e->xkey;
++ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
++
++ for (i = 0; i < LENGTH(keys); i++)
++ if (momentaryalttags
++ && keys[i].func && keys[i].func == togglealttag
++ && selmon->alttag
++ && (keysym == keys[i].keysym
++ || CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)))
++ keys[i].func(&(keys[i].arg));
++}
++
+ void
+ killclient(const Arg *arg)
+ {
+_AT_@ -1699,6 +1723,13 @@ tile(Monitor *m)
+ }
+ }
+
++void
++togglealttag()
++{
++ selmon->alttag = !selmon->alttag;
++ drawbar(selmon);
++}
++
+ void
+ togglebar(const Arg *arg)
+ {
+--
+2.33.0
+
diff --git a/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-6.2.diff b/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-6.2.diff
index dc6a0cfd..9eb8c8b8 100644
--- a/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-6.2.diff
+++ b/dwm.suckless.org/patches/alternativetags/dwm-alternativetags-6.2.diff
_AT_@ -1,32 +1,27 @@
-From 25aa44b5998a2aac840a0eecf9d8a479695b2577 Mon Sep 17 00:00:00 2001
-From: Piyush Pangtey <gokuvsvegita_AT_gmail.com>
-Date: Sat, 13 Apr 2019 00:24:23 +0530
-Subject: [PATCH] alternative tags
+From b55c4bc2efa0331a6fb521d41169e8ddf8bc9b13 Mon Sep 17 00:00:00 2001
+From: Jack Bird <jack.bird_AT_durham.ac.uk>
+Date: Sun, 29 Aug 2021 17:30:40 +0100
+Subject: [PATCH] Added momentary config option
-Having icons as tags sure makes dwm look awesome, but having tags number
-simplifies tags related operations. This patch introduces alternative
-tags which can be switched on the fly for the sole purpose of providing
-visual aid.
-
-Signed-off-by: Piyush Pangtey <gokuvsvegita_AT_gmail.com>
---
- config.def.h | 2 ++
- dwm.c | 14 ++++++++++++--
- 2 files changed, 14 insertions(+), 2 deletions(-)
+ config.def.h | 3 +++
+ dwm.c | 35 +++++++++++++++++++++++++++++++++--
+ 2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
-index 1c0b587..e6c2565 100644
+index 1c0b587..4cfcef1 100644
--- a/config.def.h
+++ b/config.def.h
-_AT_@ -20,6 +20,7 @@ static const char *colors[][3] = {
+_AT_@ -20,6 +20,8 @@ static const char *colors[][3] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const char *tagsalt[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
++static const int momentaryalttags = 0; /* 1 means alttags will show only when key is held down*/
static const Rule rules[] = {
/* xprop(1):
-_AT_@ -84,6 +85,7 @@ static Key keys[] = {
+_AT_@ -84,6 +86,7 @@ static Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
_AT_@ -35,7 +30,7 @@ index 1c0b587..e6c2565 100644
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
diff --git a/dwm.c b/dwm.c
-index 4465af1..ee292e1 100644
+index 4465af1..1e6e6f3 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -130,6 +130,7 @@ struct Monitor {
_AT_@ -46,7 +41,15 @@ index 4465af1..ee292e1 100644
};
typedef struct {
-_AT_@ -209,6 +210,7 @@ static void spawn(const Arg *arg);
+_AT_@ -176,6 +177,7 @@ static void grabbuttons(Client *c, int focused);
+ static void grabkeys(void);
+ static void incnmaster(const Arg *arg);
+ static void keypress(XEvent *e);
++static void keyrelease(XEvent *e);
+ static void killclient(const Arg *arg);
+ static void manage(Window w, XWindowAttributes *wa);
+ static void mappingnotify(XEvent *e);
+_AT_@ -209,6 +211,7 @@ static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *);
_AT_@ -54,7 +57,15 @@ index 4465af1..ee292e1 100644
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
-_AT_@ -695,7 +697,7 @@ dirtomon(int dir)
+_AT_@ -253,6 +256,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
+ [Expose] = expose,
+ [FocusIn] = focusin,
+ [KeyPress] = keypress,
++ [KeyRelease] = keyrelease,
+ [MappingNotify] = mappingnotify,
+ [MapRequest] = maprequest,
+ [MotionNotify] = motionnotify,
+_AT_@ -695,7 +699,7 @@ dirtomon(int dir)
void
drawbar(Monitor *m)
{
_AT_@ -63,7 +74,7 @@ index 4465af1..ee292e1 100644
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
-_AT_@ -716,8 +718,9 @@ drawbar(Monitor *m)
+_AT_@ -716,8 +720,9 @@ drawbar(Monitor *m)
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
_AT_@ -74,7 +85,33 @@ index 4465af1..ee292e1 100644
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
-_AT_@ -1696,6 +1699,13 @@ tile(Monitor *m)
+_AT_@ -998,6 +1003,25 @@ keypress(XEvent *e)
+ keys[i].func(&(keys[i].arg));
+ }
+
++void
++keyrelease(XEvent *e)
++{
++ unsigned int i;
++ KeySym keysym;
++ XKeyEvent *ev;
++
++ ev = &e->xkey;
++ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
++
++ for (i = 0; i < LENGTH(keys); i++)
++ if (momentaryalttags
++ && keys[i].func && keys[i].func == togglealttag
++ && selmon->alttag
++ && (keysym == keys[i].keysym
++ || CLEANMASK(keys[i].mod) == CLEANMASK(ev->state)))
++ keys[i].func(&(keys[i].arg));
++}
++
+ void
+ killclient(const Arg *arg)
+ {
+_AT_@ -1696,6 +1720,13 @@ tile(Monitor *m)
}
}
_AT_@ -89,5 +126,5 @@ index 4465af1..ee292e1 100644
togglebar(const Arg *arg)
{
--
-2.21.0
+2.33.0
diff --git a/dwm.suckless.org/patches/alternativetags/index.md b/dwm.suckless.org/patches/alternativetags/index.md
index c32ef140..e2ff3ba7 100644
--- a/dwm.suckless.org/patches/alternativetags/index.md
+++ b/dwm.suckless.org/patches/alternativetags/index.md
_AT_@ -17,8 +17,10 @@ Alternative tags
Download
--------
-* [dwm-alternativetags-6.2.diff](dwm-alternativetags-6.2.diff) (2019-04-13)
+* [dwm-alternativetags-6.2.diff](dwm-alternativetags-6.2.diff) (2021-08-29)
+* [dwm-alternativetags-20210829-ed3ab6b4.diff](dwm-alternativetags-20210829-ed3ab6b4.diff) (2021-08-29)
Author
-------
* Piyush Pangtey <gokuvsvegita_AT_gmail.com>
+* Jack Bird <jack.bird_AT_dur.ac.uk> (momentary switch)
Received on Sun Aug 29 2021 - 18:53:18 CEST
This archive was generated by hypermail 2.3.0
: Sun Aug 29 2021 - 19:00:46 CEST