Skip to content

Instantly share code, notes, and snippets.

@saidone75
Last active April 4, 2020 07:35
Show Gist options
  • Save saidone75/25d8a4204d33c5f9e571879d495d102d to your computer and use it in GitHub Desktop.
Save saidone75/25d8a4204d33c5f9e571879d495d102d to your computer and use it in GitHub Desktop.
diff -u dwm.orig/config.def.h dwm/config.def.h
--- dwm.orig/config.def.h 2020-04-04 09:24:38.222114727 +0200
+++ dwm/config.def.h 2020-04-04 09:24:48.593943166 +0200
@@ -12,10 +12,17 @@
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 },
+ /* 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 -u dwm.orig/dwm.c dwm/dwm.c
--- dwm.orig/dwm.c 2020-04-04 09:24:38.222114727 +0200
+++ dwm/dwm.c 2020-04-04 09:25:08.605433481 +0200
@@ -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 */
@@ -237,6 +237,7 @@
/* variables */
static const char broken[] = "broken";
static char stext[256];
+static char ftext[256];
static int screen;
static int sw, sh; /* X display screen geometry width, height */
static int bh, blw = 0; /* bar geometry */
@@ -695,17 +696,38 @@
void
drawbar(Monitor *m)
{
- int x, w, sw = 0;
+ int x, w, sw, j= 0;
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;
+ for (int i = 0; i < strlen(stext); i++) {
+ if (stext[i] > 31) {
+ ftext[j++] = stext[i];
+ }
+ }
+ ftext[j] = '\0';
+
/* 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);
+ sw = TEXTW(ftext) - lrpad + 2; /* 2px right padding */
+ 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) {
Common subdirectories: dwm.orig/.git and dwm/.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment