Commit: 0cf69305a3eab123d357e485f498f3ec0815af79
Parent: 0220621c985005ad9acbf290b6797248e4a8caa3
Author: dan soucy
Date: Tue, 22 Mar 2022 03:15:00 -0400
enable colored text in the status bar
This patch is an update of statuscolors patch to work with 6.3.
It is known to work up to commit bece862.
Diffstat:
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -18,10 +18,17 @@ 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 },
+ [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
@@ -61,7 +61,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 */
@@ -725,6 +725,10 @@ 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 tx = 0;
+ unsigned int ctmp;
Client *c;
if (!m->showbar)
@@ -734,7 +738,20 @@ 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);
+ for (;;) {
+ while (*ts > LENGTH(colors))
+ ts++;
+
+ ctmp = *ts;
+ *ts = '\0';
+ drw_text(drw, m->ww - tw + tx, 0, tw - tx, bh, 0, tp, 0);
+ tx += TEXTW(tp) - lrpad;
+ if (ctmp == '\0')
+ break;
+ drw_setscheme(drw, scheme[ctmp - 1]);
+ *ts = ctmp;
+ tp = ++ts;
+ }
}
for (c = m->clients; c; c = c->next) {