From 5b45f88e87c772f7bc18c86f4de7ab3bac8c39c9 Mon Sep 17 00:00:00 2001 From: Jared <7060603@hotmail.ca> Date: Fri, 26 Feb 2021 02:59:07 -0500 Subject: [PATCH] rainbowtags: Unique ClrScheme for each tag when selected Allow selected tags to be unique colours. tagselfg contains the foreground colors, and tagselbg contains the background colors. --- config.def.h | 3 +++ dwm.c | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 7054c06..0abf2f5 100644 --- a/config.def.h +++ b/config.def.h @@ -19,6 +19,9 @@ static const int topbar = 1; /* 0 means bottom bar */ /* tagging */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const char *tagselfg[] = { "#ffffff", "#ffffff", "#000000", "#000000", "#ffffff", "#ffffff", "#ffffff", "#000000", "#ffffff" }; +static const char *tagselbg[] = { "#ff0000", "#ff7f00", "#ffff00", "#00ff00", "#0000ff", "#4b0082", "#9400d3", "#ffffff", "#000000" }; + static const Rule rules[] = { /* xprop(1): * WM_CLASS(STRING) = instance, class diff --git a/dwm.c b/dwm.c index 0362114..53d7ead 100644 --- a/dwm.c +++ b/dwm.c @@ -273,6 +273,8 @@ static Window root; /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; +static ClrScheme tagscheme[LENGTH(tags)]; + /* function implementations */ void applyrules(Client *c) @@ -718,7 +720,7 @@ drawbar(Monitor *m) x = 0; for (i = 0; i < LENGTH(tags); i++) { w = TEXTW(tags[i]); - drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]); + drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &tagscheme[i] : &scheme[SchemeNorm]); drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i); drw_rect(drw, x + 1, 1, dx, dx, m == selmon && selmon->sel && selmon->sel->tags & 1 << i, occ & 1 << i, urg & 1 << i); @@ -1586,6 +1588,13 @@ setup(void) scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor); scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor); scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor); + + for (unsigned int i = 0; i < LENGTH(tags); i++) { + tagscheme[i].bg = drw_clr_create(drw, tagselbg[i]); + tagscheme[i].fg = drw_clr_create(drw, tagselfg[i]); + tagscheme[i].border = drw_clr_create(drw, selbordercolor); + } + /* init bars */ updatebars(); updatestatus(); -- 2.30.1