On Tue, Apr 13, 2021 at 01:10:20PM +0300, Yigit Colakoglu wrote:
> This patch allows the user to provide a second set of tags which are
> displayed when there is a client in that tag.
>
> ---
> config.def.h | 5 ++++-
> dwm.c | 36 +++++++++++++++++++++---------------
> 2 files changed, 25 insertions(+), 16 deletions(-)
>
> diff --git a/config.def.h b/config.def.h
> index 1c0b587..53630cf 100644
> --- a/config.def.h
> +++ b/config.def.h
> _AT_@ -19,7 +19,10 @@ static const char *colors[][3] = {
> };
>
> /* tagging */
> -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
> +static const char *tags[][9] = {
> + [VacantTags] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"},
> + [BusyTags] = {"A", "B", "C", "D", "E", "F", "G", "H", "I"}
> +};
>
> static const Rule rules[] = {
> /* xprop(1):
> diff --git a/dwm.c b/dwm.c
> index b0b3466..c7b8ceb 100644
> --- a/dwm.c
> +++ b/dwm.c
> _AT_@ -54,7 +54,7 @@
> #define MOUSEMASK (BUTTONMASK|PointerMotionMask)
> #define WIDTH(X) ((X)->w + 2 * (X)->bw)
> #define HEIGHT(X) ((X)->h + 2 * (X)->bw)
> -#define TAGMASK ((1 << LENGTH(tags)) - 1)
> +#define TAGMASK ((1 << LENGTH(tags[VacantTags])) - 1)
> #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
>
> /* enums */
> _AT_@ -66,6 +66,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
> enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
> enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
> ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
> +enum { VacantTags, BusyTags }; /* Tag Types */
>
> typedef union {
> int i;
> _AT_@ -273,7 +274,7 @@ static Window root, wmcheckwin;
> #include "config.h"
>
> /* compile-time check if all tags fit into an unsigned int bit array. */
> -struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
> +struct NumTags { char limitexceeded[LENGTH(tags[VacantTags]) > 31 ? -1 : 1]; };
>
> /* function implementations */
> void
> _AT_@ -417,7 +418,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;
> _AT_@ -432,10 +433,16 @@ buttonpress(XEvent *e)
> }
> if (ev->window == selmon->barwin) {
> i = x = 0;
> - do
> - x += TEXTW(tags[i]);
> - while (ev->x >= x && ++i < LENGTH(tags));
> - if (i < LENGTH(tags)) {
> +
> + for (c = m->clients; c; c = c->next)
> + occ |= c->tags == 255 ? 0 : c->tags;
> + do {
> + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
> + x += TEXTW(tags[VacantTags][i]);
> + else
> + x += TEXTW(tags[BusyTags][i]);
> + }while (ev->x >= x && ++i < LENGTH(tags[VacantTags]));
> + if (i < LENGTH(tags[VacantTags])) {
> click = ClkTagBar;
> arg.ui = 1 << i;
> } else if (ev->x < x + blw)
> _AT_@ -710,19 +717,18 @@ drawbar(Monitor *m)
> }
>
> for (c = m->clients; c; c = c->next) {
> - occ |= c->tags;
> + occ |= c->tags == 255 ? 0 : c->tags;
> if (c->isurgent)
> urg |= c->tags;
> }
> x = 0;
> - for (i = 0; i < LENGTH(tags); i++) {
> - w = TEXTW(tags[i]);
> + for (i = 0; i < LENGTH(tags[VacantTags]); i++) {
> + w = bh;
> 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);
> + if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
> + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[VacantTags][i], urg & 1 << i);
> + else
> + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[BusyTags][i], urg & 1 << i);
> x += w;
> }
> w = blw = TEXTW(m->ltsymbol);
> --
> 2.31.1
>
>
No thanks, but you can upload it to the wiki.
--
Kind regards,
Hiltjo
Received on Tue Apr 13 2021 - 13:36:55 CEST