sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-statuscolors-20220322-bece862.diff (2841B)


      1 From 301db3986527041d64f4b58026677709a34b153f Mon Sep 17 00:00:00 2001
      2 From: dan soucy <dev@danso.ca>
      3 Date: Tue, 22 Mar 2022 03:15:00 -0400
      4 Subject: [PATCH] enable colored text in the status bar
      5 
      6 This patch is an update of statuscolors patch to work with 6.3.
      7 It is known to work up to commit bece862.
      8 ---
      9  config.def.h | 13 ++++++++++---
     10  dwm.c        | 18 ++++++++++++++++--
     11  2 files changed, 26 insertions(+), 5 deletions(-)
     12 
     13 diff --git a/config.def.h b/config.def.h
     14 index a2ac963..a635f76 100644
     15 --- a/config.def.h
     16 +++ b/config.def.h
     17 @@ -12,10 +12,17 @@ static const char col_gray2[]       = "#444444";
     18  static const char col_gray3[]       = "#bbbbbb";
     19  static const char col_gray4[]       = "#eeeeee";
     20  static const char col_cyan[]        = "#005577";
     21 +static const char col_black[]       = "#000000";
     22 +static const char col_red[]         = "#ff0000";
     23 +static const char col_yellow[]      = "#ffff00";
     24 +static const char col_white[]       = "#ffffff";
     25 +
     26  static const char *colors[][3]      = {
     27 -	/*               fg         bg         border   */
     28 -	[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
     29 -	[SchemeSel]  = { col_gray4, col_cyan,  col_cyan  },
     30 +	/*					fg         bg          border   */
     31 +	[SchemeNorm] =	 { col_gray3, col_gray1,  col_gray2 },
     32 +	[SchemeSel]  =	 { col_gray4, col_cyan,   col_cyan },
     33 +	[SchemeWarn] =	 { col_black, col_yellow, col_red },
     34 +	[SchemeUrgent]=	 { col_white, col_red,    col_red },
     35  };
     36  
     37  /* tagging */
     38 diff --git a/dwm.c b/dwm.c
     39 index 5f16260..3c5e26b 100644
     40 --- a/dwm.c
     41 +++ b/dwm.c
     42 @@ -59,7 +59,7 @@
     43  
     44  /* enums */
     45  enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
     46 -enum { SchemeNorm, SchemeSel }; /* color schemes */
     47 +enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent }; /* color schemes */
     48  enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
     49         NetWMFullscreen, NetActiveWindow, NetWMWindowType,
     50         NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
     51 @@ -701,6 +701,10 @@ drawbar(Monitor *m)
     52  	int boxs = drw->fonts->h / 9;
     53  	int boxw = drw->fonts->h / 6 + 2;
     54  	unsigned int i, occ = 0, urg = 0;
     55 +	char *ts = stext;
     56 +	char *tp = stext;
     57 +	int tx = 0;
     58 +	char ctmp;
     59  	Client *c;
     60  
     61  	if (!m->showbar)
     62 @@ -710,7 +714,17 @@ drawbar(Monitor *m)
     63  	if (m == selmon) { /* status is only drawn on selected monitor */
     64  		drw_setscheme(drw, scheme[SchemeNorm]);
     65  		tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
     66 -		drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
     67 +		while (1) {
     68 +			if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; }
     69 +			ctmp = *ts;
     70 +			*ts = '\0';
     71 +			drw_text(drw, m->ww - tw + tx, 0, tw - tx, bh, 0, tp, 0);
     72 +			tx += TEXTW(tp) -lrpad;
     73 +			if (ctmp == '\0') { break; }
     74 +			drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]);
     75 +			*ts = ctmp;
     76 +			tp = ++ts;
     77 +		}
     78  	}
     79  
     80  	for (c = m->clients; c; c = c->next) {
     81 -- 
     82 2.35.1
     83