From df9bee20a25b55b1ba37d635c9fcbd242ba0c4ad Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sat, 30 Apr 2022 18:57:28 +0200 Subject: [PATCH] Add statusbar colors --- .suckless/dwm/config.h | 15 ++++++++++++--- .suckless/dwm/dwm.c | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.suckless/dwm/config.h b/.suckless/dwm/config.h index fa9c048..06ce3d5 100644 --- a/.suckless/dwm/config.h +++ b/.suckless/dwm/config.h @@ -12,11 +12,20 @@ static const char col_gray0[] = "#0a0a0a"; static const char col_gray1[] = "#111111"; static const char col_gray2[] = "#333333"; static const char col_gray3[] = "#555555"; +// Warn & urgent colors static const char col_gray4[] = "#cccccc"; +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_gray0, col_gray0 }, - [SchemeSel] = { col_gray4, col_gray0, col_gray2 }, + /* fg bg border */ + [SchemeNorm] = { col_gray4, col_gray0, col_gray2 }, + [SchemeSel] = { col_white, col_gray0, col_gray3 }, + // Extra color schemes + [SchemeWarn] = { col_black, col_yellow, col_red }, + [SchemeUrgent]= { col_white, col_red, col_red }, }; /* tagging */ diff --git a/.suckless/dwm/dwm.c b/.suckless/dwm/dwm.c index 5954fad..34bc64f 100644 --- a/.suckless/dwm/dwm.c +++ b/.suckless/dwm/dwm.c @@ -60,7 +60,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 */ @@ -729,13 +729,27 @@ 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; + char ctmp; 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); + while (1) { + if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; } + ctmp = *ts; + *ts = '\0'; + drw_text(drw, m->ww - sw + tx, 0, sw - tx, bh, 0, tp, 0); + tx += TEXTW(tp) -lrpad; + if (ctmp == '\0') { break; } + drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); + *ts = ctmp; + tp = ++ts; + } } for (c = m->clients; c; c = c->next) {