sites

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

commit 296a7f6b833828f201c554db6b4ec7ae32aecd97
parent 8d16e953a8896690cdb036e07925c540984eed56
Author: Timmy Keller <applesrcol8796@gmail.com>
Date:   Mon, 15 Mar 2021 21:29:49 -0500

[dwm][patch] adds taglabels patch

Diffstat:
Adwm.suckless.org/patches/taglabels/dwm-taglabels+hide_vacant_tags-6.2.diff | 114+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/taglabels/dwm-taglabels-6.2.diff | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/taglabels/dwm-taglabels-hide_vacant_tags_funcionality-6.2.diff | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/taglabels/index.md | 21+++++++++++++++++++++
4 files changed, 313 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/taglabels/dwm-taglabels+hide_vacant_tags-6.2.diff b/dwm.suckless.org/patches/taglabels/dwm-taglabels+hide_vacant_tags-6.2.diff @@ -0,0 +1,114 @@ +diff -pu dwm.git/config.def.h dwm.programtags+hidewithvacanttags/config.def.h +--- dwm.git/config.def.h 2021-02-27 20:04:32.030570909 -0600 ++++ dwm.programtags+hidewithvacanttags/config.def.h 2021-03-15 16:32:37.586956549 -0500 +@@ -21,6 +21,10 @@ static const char *colors[][3] = { + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++static const char ptagf[] = "[%s %s]"; /* format of a tag label */ ++static const char etagf[] = "[%s]"; /* format of an empty tag */ ++static const int lcaselbl = 0; /* 1 means make tag label lowercase */ ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +diff -pu dwm.git/dwm.c dwm.programtags+hidewithvacanttags/dwm.c +--- dwm.git/dwm.c 2021-02-27 20:04:32.030570909 -0600 ++++ dwm.programtags+hidewithvacanttags/dwm.c 2021-03-15 16:32:23.693639390 -0500 +@@ -20,6 +20,7 @@ + * + * To understand everything else, start reading main(). + */ ++#include <ctype.h> /* for tolower function, very tiny standard library */ + #include <errno.h> + #include <locale.h> + #include <signal.h> +@@ -272,6 +273,8 @@ static Window root, wmcheckwin; + /* configuration, allows nested code to access above variables */ + #include "config.h" + ++unsigned int tagw[LENGTH(tags)]; ++ + /* compile-time check if all tags fit into an unsigned int bit array. */ + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + +@@ -417,7 +420,7 @@ attachstack(Client *c) + void + buttonpress(XEvent *e) + { +- unsigned int i, x, click; ++ unsigned int i, x, click, occ = 0; + Arg arg = {0}; + Client *c; + Monitor *m; +@@ -432,9 +435,14 @@ buttonpress(XEvent *e) + } + if (ev->window == selmon->barwin) { + i = x = 0; +- do +- x += TEXTW(tags[i]); +- while (ev->x >= x && ++i < LENGTH(tags)); ++ for (c = m->clients; c; c = c->next) ++ occ |= c->tags == 255 ? 0 : c->tags; ++ do { ++ /* do not reserve space for vacant tags */ ++ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) ++ continue; ++ x += tagw[i]; ++ } while (ev->x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + click = ClkTagBar; + arg.ui = 1 << i; +@@ -701,6 +709,8 @@ drawbar(Monitor *m) + int boxw = drw->fonts->h / 6 + 2; + unsigned int i, occ = 0, urg = 0; + Client *c; ++ char tagdisp[64]; ++ char *masterclientontag[LENGTH(tags)]; + + /* draw status first so it can be overdrawn by tags later */ + if (m == selmon) { /* status is only drawn on selected monitor */ +@@ -709,20 +719,36 @@ drawbar(Monitor *m) + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); + } + ++ for (i = 0; i < LENGTH(tags); i++) ++ masterclientontag[i] = NULL; ++ + for (c = m->clients; c; c = c->next) { +- occ |= c->tags; ++ occ |= c->tags == 255 ? 0 : c->tags; + if (c->isurgent) + urg |= c->tags; ++ for (i = 0; i < LENGTH(tags); i++) ++ if (!masterclientontag[i] && c->tags & (1<<i)) { ++ XClassHint ch = { NULL, NULL }; ++ XGetClassHint(dpy, c->win, &ch); ++ masterclientontag[i] = ch.res_class; ++ if (lcaselbl) ++ masterclientontag[i][0] = tolower(masterclientontag[i][0]); ++ } + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { +- w = TEXTW(tags[i]); ++ /* do not draw vacant tags */ ++ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) ++ continue; ++ ++ if (masterclientontag[i]) ++ snprintf(tagdisp, 64, ptagf, tags[i], masterclientontag[i]); ++ else ++ snprintf(tagdisp, 64, etagf, tags[i]); ++ masterclientontag[i] = tagdisp; ++ tagw[i] = w = TEXTW(masterclientontag[i]); + 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); +- if (occ & 1 << i) +- drw_rect(drw, x + boxs, boxs, boxw, boxw, +- m == selmon && selmon->sel && selmon->sel->tags & 1 << i, +- urg & 1 << i); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, masterclientontag[i], urg & 1 << i); + x += w; + } + w = blw = TEXTW(m->ltsymbol); diff --git a/dwm.suckless.org/patches/taglabels/dwm-taglabels-6.2.diff b/dwm.suckless.org/patches/taglabels/dwm-taglabels-6.2.diff @@ -0,0 +1,87 @@ +diff -pu dwm.git/config.def.h dwm.programtags/config.def.h +--- dwm.git/config.def.h 2021-02-27 20:04:32.030570909 -0600 ++++ dwm.programtags/config.def.h 2021-03-15 16:24:23.620864957 -0500 +@@ -21,6 +21,10 @@ static const char *colors[][3] = { + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++static const char ptagf[] = "[%s %s]"; /* format of a tag label */ ++static const char etagf[] = "[%s]"; /* format of an empty tag */ ++static const int lcaselbl = 0; /* 1 means make tag label lowercase */ ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +diff -pu dwm.git/dwm.c dwm.programtags/dwm.c +--- dwm.git/dwm.c 2021-02-27 20:04:32.030570909 -0600 ++++ dwm.programtags/dwm.c 2021-03-15 16:30:13.580457535 -0500 +@@ -20,6 +20,7 @@ + * + * To understand everything else, start reading main(). + */ ++#include <ctype.h> /* for making tab label lowercase, very tiny standard library */ + #include <errno.h> + #include <locale.h> + #include <signal.h> +@@ -272,6 +273,8 @@ static Window root, wmcheckwin; + /* configuration, allows nested code to access above variables */ + #include "config.h" + ++unsigned int tagw[LENGTH(tags)]; ++ + /* compile-time check if all tags fit into an unsigned int bit array. */ + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + +@@ -433,7 +436,7 @@ buttonpress(XEvent *e) + if (ev->window == selmon->barwin) { + i = x = 0; + do +- x += TEXTW(tags[i]); ++ x += tagw[i]; + while (ev->x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + click = ClkTagBar; +@@ -701,6 +704,8 @@ drawbar(Monitor *m) + int boxw = drw->fonts->h / 6 + 2; + unsigned int i, occ = 0, urg = 0; + Client *c; ++ char taglabel[64]; ++ char *masterclientontag[LENGTH(tags)]; + + /* draw status first so it can be overdrawn by tags later */ + if (m == selmon) { /* status is only drawn on selected monitor */ +@@ -709,16 +714,32 @@ drawbar(Monitor *m) + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); + } + ++ for (i = 0; i < LENGTH(tags); i++) ++ masterclientontag[i] = NULL; ++ + for (c = m->clients; c; c = c->next) { + occ |= c->tags; + if (c->isurgent) + urg |= c->tags; ++ for (i = 0; i < LENGTH(tags); i++) ++ if (!masterclientontag[i] && c->tags & (1<<i)) { ++ XClassHint ch = { NULL, NULL }; ++ XGetClassHint(dpy, c->win, &ch); ++ masterclientontag[i] = ch.res_class; ++ if (lcaselbl) ++ masterclientontag[i][0] = tolower(masterclientontag[i][0]); ++ } + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { +- w = TEXTW(tags[i]); ++ if (masterclientontag[i]) ++ snprintf(taglabel, 64, ptagf, tags[i], masterclientontag[i]); ++ else ++ snprintf(taglabel, 64, etagf, tags[i]); ++ masterclientontag[i] = taglabel; ++ tagw[i] = w = TEXTW(masterclientontag[i]); + 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, lrpad / 2, masterclientontag[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, diff --git a/dwm.suckless.org/patches/taglabels/dwm-taglabels-hide_vacant_tags_funcionality-6.2.diff b/dwm.suckless.org/patches/taglabels/dwm-taglabels-hide_vacant_tags_funcionality-6.2.diff @@ -0,0 +1,91 @@ +diff -pu dwm.hide_vacant_tags/config.def.h dwm.programtags+hidewithvacanttags/config.def.h +--- dwm.hide_vacant_tags/config.def.h 2021-03-15 16:37:24.586622415 -0500 ++++ dwm.programtags+hidewithvacanttags/config.def.h 2021-03-15 16:32:37.586956549 -0500 +@@ -21,6 +21,10 @@ static const char *colors[][3] = { + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++static const char ptagf[] = "[%s %s]"; /* format of a tag label */ ++static const char etagf[] = "[%s]"; /* format of an empty tag */ ++static const int lcaselbl = 0; /* 1 means make tag label lowercase */ ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +diff -pu dwm.hide_vacant_tags/dwm.c dwm.programtags+hidewithvacanttags/dwm.c +--- dwm.hide_vacant_tags/dwm.c 2021-03-15 16:37:38.189939908 -0500 ++++ dwm.programtags+hidewithvacanttags/dwm.c 2021-03-15 16:32:23.693639390 -0500 +@@ -20,6 +20,7 @@ + * + * To understand everything else, start reading main(). + */ ++#include <ctype.h> /* for making tab label lowercase, very tiny standard library */ + #include <errno.h> + #include <locale.h> + #include <signal.h> +@@ -272,6 +273,8 @@ static Window root, wmcheckwin; + /* configuration, allows nested code to access above variables */ + #include "config.h" + ++unsigned int tagw[LENGTH(tags)]; ++ + /* compile-time check if all tags fit into an unsigned int bit array. */ + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + +@@ -438,7 +441,7 @@ buttonpress(XEvent *e) + /* do not reserve space for vacant tags */ + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; +- x += TEXTW(tags[i]); ++ x += tagw[i]; + } while (ev->x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + click = ClkTagBar; +@@ -706,6 +709,8 @@ drawbar(Monitor *m) + int boxw = drw->fonts->h / 6 + 2; + unsigned int i, occ = 0, urg = 0; + Client *c; ++ char tagdisp[64]; ++ char *masterclientontag[LENGTH(tags)]; + + /* draw status first so it can be overdrawn by tags later */ + if (m == selmon) { /* status is only drawn on selected monitor */ +@@ -714,10 +719,21 @@ drawbar(Monitor *m) + drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); + } + ++ for (i = 0; i < LENGTH(tags); i++) ++ masterclientontag[i] = NULL; ++ + for (c = m->clients; c; c = c->next) { + occ |= c->tags == 255 ? 0 : c->tags; + if (c->isurgent) + urg |= c->tags; ++ for (i = 0; i < LENGTH(tags); i++) ++ if (!masterclientontag[i] && c->tags & (1<<i)) { ++ XClassHint ch = { NULL, NULL }; ++ XGetClassHint(dpy, c->win, &ch); ++ masterclientontag[i] = ch.res_class; ++ if (lcaselbl) ++ masterclientontag[i][0] = tolower(masterclientontag[i][0]); ++ } + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { +@@ -725,9 +741,14 @@ drawbar(Monitor *m) + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) + continue; + +- w = TEXTW(tags[i]); ++ if (masterclientontag[i]) ++ snprintf(tagdisp, 64, ptagf, tags[i], masterclientontag[i]); ++ else ++ snprintf(tagdisp, 64, etagf, tags[i]); ++ masterclientontag[i] = tagdisp; ++ tagw[i] = w = TEXTW(masterclientontag[i]); + 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, lrpad / 2, masterclientontag[i], urg & 1 << i); + x += w; + } + w = blw = TEXTW(m->ltsymbol); diff --git a/dwm.suckless.org/patches/taglabels/index.md b/dwm.suckless.org/patches/taglabels/index.md @@ -0,0 +1,21 @@ +taglabels +========= + +Description +----------- +Displays the executable name of each tag's current master client after the tag name in the dwm bar. +* For example, if `st` is the master client on tag `1`, then the bar would display `[1: st]` as opposed to just `1`. + +The format of the label, for both non-empty and empty tags, is configurable through the configuration variables `ptagf` and `etagf` respectively. There is also a config variable, `lcaselbl`, that, when enabled, makes the first letter lowercase (out of personal preference). + +Download +-------- +* [dwm-taglabels-6.2.diff](dwm-taglabels-6.2.diff) + +This patch looks best with [hide\_vacant\_tags](../hide_vacant_tags), and, as such, there are seperate versions that support that patch (since, by default, they conflict badly). +* [dwm-taglabels-hide\_vacant\_tags\_funcionality-6.2.diff](dwm-taglabels-hide_vacant_tags_funcionality-6.2.diff) (install on top of hide\_vacant\_tags) +* [dwm-taglabels+hide\_vacant\_tags-6.2.diff](dwm-taglabels+hide_vacant_tags-6.2.diff) (comes with both patches for simplicity's sake) + +Author +------ +* Timmy Keller <applesrcol8796@gmail.com>