From 4594e13a77d9d6bdf48b763196c5101ba55a0738 Mon Sep 17 00:00:00 2001 From: Jakub Date: Thu, 11 Jul 2024 17:03:51 -0400 Subject: [PATCH] rainbow tags patch --- config.def.h | 14 +++++ dwm.c | 8 ++- .../appearance/dwm-rainbowtags-6.2-alpha.diff | 61 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 patches/bar/appearance/dwm-rainbowtags-6.2-alpha.diff diff --git a/config.def.h b/config.def.h index 275acd9..bb9b641 100644 --- a/config.def.h +++ b/config.def.h @@ -58,6 +58,20 @@ static const unsigned int ulinestroke = 2; /* thickness / height of the underlin static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */ static const int ulineall = 0; /* 1 to show underline on all tags, 0 for just the active ones */ +static const char *tagsel[][2] = { + { "#ffffff", "#ff0000" }, + { "#ffffff", "#ff7f00" }, + { "#000000", "#ffff00" }, + { "#000000", "#00ff00" }, + { "#ffffff", "#0000ff" }, + { "#ffffff", "#4b0082" }, + { "#ffffff", "#9400d3" }, + { "#000000", "#ffffff" }, + { "#ffffff", "#000000" }, +}; + +static const unsigned int tagalpha[] = { OPAQUE, baralpha }; + static const Rule rules[] = { /* xprop(1): * WM_CLASS(STRING) = instance, class diff --git a/dwm.c b/dwm.c index f731ab6..0c8a74b 100644 --- a/dwm.c +++ b/dwm.c @@ -335,6 +335,7 @@ static int restart = 0; static int running = 1; static Cur *cursor[CurLast]; static Clr **scheme; +static Clr **tagscheme; static Display *dpy; static Drw *drw; static Monitor *mons, *selmon; @@ -962,7 +963,7 @@ drawbar(Monitor *m) if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) continue; w = TEXTW(tags[i]); - drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeNorm : SchemeNorm]); + drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[SchemeNorm])); drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); if (ulineall || m->tagset[m->seltags] & 1 << i) { /* if there are conflicts, just move these lines directly underneath both 'drw_setscheme' and 'drw_text' :) */ @@ -2506,9 +2507,14 @@ setup(void) cursor[CurResize] = drw_cur_create(drw, XC_sizing); cursor[CurMove] = drw_cur_create(drw, XC_fleur); /* init appearance */ + if (LENGTH(tags) > LENGTH(tagsel)) + die("too few color schemes for the tags"); scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); for (i = 0; i < LENGTH(colors); i++) scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); + tagscheme = ecalloc(LENGTH(tagsel), sizeof(Clr *)); + for (i = 0; i < LENGTH(tagsel); i++) + tagscheme[i] = drw_scm_create(drw, tagsel[i], tagalpha, 2); /* init bars */ updatebars(); updatestatus(); diff --git a/patches/bar/appearance/dwm-rainbowtags-6.2-alpha.diff b/patches/bar/appearance/dwm-rainbowtags-6.2-alpha.diff new file mode 100644 index 0000000..8701b19 --- /dev/null +++ b/patches/bar/appearance/dwm-rainbowtags-6.2-alpha.diff @@ -0,0 +1,61 @@ +diff --git a/config.def.h b/config.def.h +index 1c0b587..80d0e6e 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -21,6 +21,20 @@ static const char *colors[][3] = { + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++static const char *tagsel[][2] = { ++ { "#ffffff", "#ff0000" }, ++ { "#ffffff", "#ff7f00" }, ++ { "#000000", "#ffff00" }, ++ { "#000000", "#00ff00" }, ++ { "#ffffff", "#0000ff" }, ++ { "#ffffff", "#4b0082" }, ++ { "#ffffff", "#9400d3" }, ++ { "#000000", "#ffffff" }, ++ { "#ffffff", "#000000" }, ++}; ++ ++static const unsigned int tagalpha[] = { OPAQUE, baralpha }; ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +diff --git a/dwm.c b/dwm.c +index b0b3466..23d1c46 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -264,6 +264,7 @@ static Atom wmatom[WMLast], netatom[NetLast]; + static int running = 1; + static Cur *cursor[CurLast]; + static Clr **scheme; ++static Clr **tagscheme; + static Display *dpy; + static Drw *drw; + static Monitor *mons, *selmon; +@@ -717,7 +718,7 @@ drawbar(Monitor *m) + x = 0; + for (i = 0; i < LENGTH(tags); i++) { + w = TEXTW(tags[i]); +- drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); ++ drw_setscheme(drw, (m->tagset[m->seltags] & 1 << i ? tagscheme[i] : scheme[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, +@@ -1568,9 +1569,14 @@ setup(void) + cursor[CurResize] = drw_cur_create(drw, XC_sizing); + cursor[CurMove] = drw_cur_create(drw, XC_fleur); + /* init appearance */ ++ if (LENGTH(tags) > LENGTH(tagsel)) ++ die("too few color schemes for the tags"); + scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); + for (i = 0; i < LENGTH(colors); i++) + scheme[i] = drw_scm_create(drw, colors[i], 3); ++ tagscheme = ecalloc(LENGTH(tagsel), sizeof(Clr *)); ++ for (i = 0; i < LENGTH(tagsel); i++) ++ tagscheme[i] = drw_scm_create(drw, tagsel[i], tagalpha, 2); + /* init bars */ + updatebars(); + updatestatus();