commit b9842c1e781fb0d4ccf07a8f9175c6c5e5e48c41 from: Benjamin Stürz date: Sun Aug 04 12:22:52 2024 UTC dwm: add ability to color statusbar commit - 97ace6159e6d535692dbd9f49b2422aecaa94e5f commit + b9842c1e781fb0d4ccf07a8f9175c6c5e5e48c41 blob - df0314dddc4bdf6486df63a6c1da5280836aa2f9 blob + cfd9c825f524ac24c236f8f99534618c070fe9ca --- dwm/config.h +++ dwm/config.h @@ -15,10 +15,14 @@ static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_cyan[] = "#2255ff"; -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +static const char col_yellow[] = "#ffff00"; +static const char col_red[] = "#ff0000"; +static const char *colors[][NumSchemes] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeWarn] = { col_yellow, col_gray1, col_gray2 }, + [SchemeUrgent] = { col_red, col_gray1, col_gray2 }, }; /* tagging */ blob - 207a4e63174bc1bcb7dbbb7586661c8ec8a288f9 blob + 83746c84894c2c4f4ecf6736bd1722ccf5449e3e --- dwm/dwm.c +++ dwm/dwm.c @@ -60,7 +60,7 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent, NumSchemes }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ @@ -744,10 +744,11 @@ dirtomon(int dir) void drawbar(Monitor *m) { - int x, w, tw = 0; + int ch, tx = 0, x, w, tw = 0; int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; + char *ts = stext, *tp = stext; Client *c; if (!m->showbar) @@ -757,7 +758,23 @@ drawbar(Monitor *m) if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); + while (1) { + if ((size_t)*ts > LENGTH(colors)) { + ++ts; + continue; + } + + ch = *ts; + *ts = '\0'; + drw_text(drw, m->ww - tw + tx, 0, tw - tx, bh, 0, tp, 0); + tx += TEXTW(tp) - lrpad; + if (ch == '\0') + break; + drw_setscheme(drw, scheme[(size_t)(ch - 1)]); + *ts = ch; + ++ts; + tp = ts; + } } for (c = m->clients; c; c = c->next) {