From a52bfcf3102985f97096baaf8e38c4d0389135c8 Mon Sep 17 00:00:00 2001 From: prempaolo Date: Fri, 3 Apr 2020 16:47:50 +0200 Subject: [PATCH] statuscolor patch update --- config.def.h | 6 ++++++ dwm.c | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 1c0b587..93a9e5e 100644 --- a/config.def.h +++ b/config.def.h @@ -12,10 +12,16 @@ static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_cyan[] = "#005577"; +static const char col_black[] = "#000000"; +static const char col_red[] = "#ff0000"; +static const char col_yellow[] = "#ffff00"; +static const char col_white[] = "#ffffff"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeWarn] = { col_black, col_yellow, col_red }, + [SchemeUrgent]= { col_white, col_red, col_red }, }; /* tagging */ diff --git a/dwm.c b/dwm.c index 4465af1..6c0c514 100644 --- a/dwm.c +++ b/dwm.c @@ -59,7 +59,7 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ @@ -699,13 +699,40 @@ drawbar(Monitor *m) int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; + char *ts = stext; + char *tp = stext; + int tsw, tpw, tx = 0; Client *c; /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); + int counter=0; + char tmp[3]; + while (*(tp+2) != '\0') { + if (*tp == 91 && *(tp+2) == 93) { + tmp[0]=*tp; + tmp[1]=*(tp+1); + tmp[2]=*(tp+2); + counter += TEXTW(tmp) - lrpad; + } + tp++; + } + sw = TEXTW(stext) - lrpad + 2 - counter; + tp = ts; + while (*(tp+2) != '\0') { + if (*tp == 91 && (unsigned int)*(tp+1) < (LENGTH(colors)+49) && *(tp+2) == 93) { + drw_text(drw, m->ww - sw + tx, 0, sw - tx, bh, 0, ts, 0); + drw_setscheme(drw, scheme[(unsigned int) *(tp+1)-49]); + tpw = TEXTW(tp) - lrpad; + tsw = TEXTW(ts) - lrpad; + tx += tsw - tpw; + ts = tp+3; + tp = tp+2; + } + tp++; + } + drw_text(drw, m->ww - sw + tx, 0, sw - tx, bh, 0, ts, 0); } for (c = m->clients; c; c = c->next) { -- 2.26.0