status2d patch
This commit is contained in:
parent
c361ca2c0d
commit
aa97ffdf35
143
dwm.c
143
dwm.c
@ -192,6 +192,7 @@ static void detachstack(Client *c);
|
||||
static Monitor *dirtomon(int dir);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
static int drawstatusbar(Monitor *m, int bh, int extra, char* text);
|
||||
static void enternotify(XEvent *e);
|
||||
static void expose(XEvent *e);
|
||||
static Client *findbefore(Client *c);
|
||||
@ -296,8 +297,8 @@ static pid_t winpid(Window w);
|
||||
/* variables */
|
||||
static Client *prevzoom = NULL;
|
||||
static const char broken[] = "broken";
|
||||
static char stext[256];
|
||||
static char estext[256];
|
||||
static char stext[1024];
|
||||
static char estext[1024];
|
||||
static char wfsymbol[2];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
@ -688,7 +689,7 @@ cleanup(void)
|
||||
cleanupmon(mons);
|
||||
for (i = 0; i < CurLast; i++)
|
||||
drw_cur_free(drw, cursor[i]);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
for (i = 0; i < LENGTH(colors) + 1; i++)
|
||||
free(scheme[i]);
|
||||
free(scheme);
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
@ -921,6 +922,127 @@ dirtomon(int dir)
|
||||
return m;
|
||||
}
|
||||
|
||||
int
|
||||
drawstatusbar(Monitor *m, int bh, int extra, char* stext) {
|
||||
int ret, i, w, x, len;
|
||||
short isCode = 0;
|
||||
char *text;
|
||||
char *p;
|
||||
Clr oldbg, oldfg;
|
||||
|
||||
len = strlen(stext) + 1 ;
|
||||
if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||
die("malloc");
|
||||
p = text;
|
||||
memcpy(text, stext, len);
|
||||
|
||||
/* compute width of the status text */
|
||||
w = 0;
|
||||
i = -1;
|
||||
while (text[++i]) {
|
||||
if (text[i] == '^') {
|
||||
if (!isCode) {
|
||||
isCode = 1;
|
||||
text[i] = '\0';
|
||||
w += TEXTW(text) - lrpad;
|
||||
text[i] = '^';
|
||||
if (text[++i] == 'f')
|
||||
w += atoi(text + ++i);
|
||||
} else {
|
||||
isCode = 0;
|
||||
text = text + i + 1;
|
||||
i = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isCode)
|
||||
w += TEXTW(text) - lrpad;
|
||||
else
|
||||
isCode = 0;
|
||||
text = p;
|
||||
|
||||
w += 2; /* 1px padding on both sides */
|
||||
|
||||
ret = x = m->ww - w - 2 * sp;
|
||||
|
||||
drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
x++;
|
||||
|
||||
/* process status text */
|
||||
i = -1;
|
||||
while (text[++i]) {
|
||||
if (text[i] == '^' && !isCode) {
|
||||
isCode = 1;
|
||||
|
||||
text[i] = '\0';
|
||||
w = TEXTW(text) - lrpad;
|
||||
drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
|
||||
x += w;
|
||||
|
||||
/* process code */
|
||||
while (text[++i] != '^') {
|
||||
if (text[i] == 'c') {
|
||||
char buf[8];
|
||||
memcpy(buf, (char*)text+i+1, 7);
|
||||
buf[7] = '\0';
|
||||
drw_clr_create(drw, &drw->scheme[ColFg], buf, 230);
|
||||
i += 7;
|
||||
} else if (text[i] == 'b') {
|
||||
char buf[8];
|
||||
memcpy(buf, (char*)text+i+1, 7);
|
||||
buf[7] = '\0';
|
||||
drw_clr_create(drw, &drw->scheme[ColBg], buf, 230);
|
||||
i += 7;
|
||||
} else if (text[i] == 'd') {
|
||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
} else if (text[i] == 'w') {
|
||||
Clr swp;
|
||||
swp = drw->scheme[ColFg];
|
||||
drw->scheme[ColFg] = drw->scheme[ColBg];
|
||||
drw->scheme[ColBg] = swp;
|
||||
} else if (text[i] == 'v') {
|
||||
oldfg = drw->scheme[ColFg];
|
||||
oldbg = drw->scheme[ColBg];
|
||||
} else if (text[i] == 't') {
|
||||
drw->scheme[ColFg] = oldfg;
|
||||
drw->scheme[ColBg] = oldbg;
|
||||
} else if (text[i] == 'r') {
|
||||
int rx = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
int ry = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
int rw = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
int rh = atoi(text + ++i);
|
||||
|
||||
drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
|
||||
} else if (text[i] == 'f') {
|
||||
x += atoi(text + ++i);
|
||||
}
|
||||
}
|
||||
|
||||
text = text + i + 1;
|
||||
i=-1;
|
||||
isCode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isCode) {
|
||||
w = TEXTW(text) - lrpad;
|
||||
drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
}
|
||||
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
free(p);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
@ -935,9 +1057,10 @@ drawbar(Monitor *m)
|
||||
return;
|
||||
|
||||
/* draw status first so it can be overdrawn by tags later */
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
drw_text(drw, m->ww - tw - 2 * sp, 0, tw, bh, 0, stext, 0);
|
||||
/* drw_setscheme(drw, scheme[SchemeNorm]); */
|
||||
/* tw = TEXTW(stext) - lrpad + 2; */ /* 2px right padding */
|
||||
/* drw_text(drw, m->ww - tw - 2 * sp, 0, tw, bh, 0, stext, 0); */
|
||||
tw = m->ww - drawstatusbar(m, bh, 0, stext);
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
if (ISVISIBLE(c))
|
||||
@ -1022,8 +1145,9 @@ drawbar(Monitor *m)
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
/* clear default bar draw buffer by drawing a blank rectangle */
|
||||
drw_rect(drw, 0, 0, m->ww, bh, 1, 1);
|
||||
w = TEXTW(estext) - lrpad + 2; /* 2px right padding */
|
||||
drw_text(drw, m->ww - w - 2 * sp, 0, w, bh, 0, estext, 0);
|
||||
/* w = TEXTW(estext) - lrpad + 2; */ /* 2px right padding */
|
||||
/* drw_text(drw, m->ww - w - 2 * sp, 0, w, bh, 0, estext, 0); */
|
||||
w = drawstatusbar(m, bh, 1, estext);
|
||||
|
||||
x = 0;
|
||||
for (i = 0; i < LENGTH(launchers); i++)
|
||||
@ -2266,7 +2390,8 @@ setup(void)
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||
scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
|
||||
scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], alphas[0], 3);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);
|
||||
/* init bars */
|
||||
|
166
patches/functions/dwm-status2d-6.3.diff
Normal file
166
patches/functions/dwm-status2d-6.3.diff
Normal file
@ -0,0 +1,166 @@
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index a96f33c..24b1eeb 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -163,6 +163,7 @@ static void detachstack(Client *c);
|
||||
static Monitor *dirtomon(int dir);
|
||||
static void drawbar(Monitor *m);
|
||||
static void drawbars(void);
|
||||
+static int drawstatusbar(Monitor *m, int bh, char* text);
|
||||
static void enternotify(XEvent *e);
|
||||
static void expose(XEvent *e);
|
||||
static void focus(Client *c);
|
||||
@@ -237,7 +238,7 @@ static void zoom(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
-static char stext[256];
|
||||
+static char stext[1024];
|
||||
static int screen;
|
||||
static int sw, sh; /* X display screen geometry width, height */
|
||||
static int bh, blw = 0; /* bar geometry */
|
||||
@@ -485,7 +486,7 @@ cleanup(void)
|
||||
cleanupmon(mons);
|
||||
for (i = 0; i < CurLast; i++)
|
||||
drw_cur_free(drw, cursor[i]);
|
||||
- for (i = 0; i < LENGTH(colors); i++)
|
||||
+ for (i = 0; i < LENGTH(colors) + 1; i++)
|
||||
free(scheme[i]);
|
||||
XDestroyWindow(dpy, wmcheckwin);
|
||||
drw_free(drw);
|
||||
@@ -693,6 +694,114 @@ dirtomon(int dir)
|
||||
return m;
|
||||
}
|
||||
|
||||
+int
|
||||
+drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||
+ int ret, i, w, x, len;
|
||||
+ short isCode = 0;
|
||||
+ char *text;
|
||||
+ char *p;
|
||||
+
|
||||
+ len = strlen(stext) + 1 ;
|
||||
+ if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||
+ die("malloc");
|
||||
+ p = text;
|
||||
+ memcpy(text, stext, len);
|
||||
+
|
||||
+ /* compute width of the status text */
|
||||
+ w = 0;
|
||||
+ i = -1;
|
||||
+ while (text[++i]) {
|
||||
+ if (text[i] == '^') {
|
||||
+ if (!isCode) {
|
||||
+ isCode = 1;
|
||||
+ text[i] = '\0';
|
||||
+ w += TEXTW(text) - lrpad;
|
||||
+ text[i] = '^';
|
||||
+ if (text[++i] == 'f')
|
||||
+ w += atoi(text + ++i);
|
||||
+ } else {
|
||||
+ isCode = 0;
|
||||
+ text = text + i + 1;
|
||||
+ i = -1;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (!isCode)
|
||||
+ w += TEXTW(text) - lrpad;
|
||||
+ else
|
||||
+ isCode = 0;
|
||||
+ text = p;
|
||||
+
|
||||
+ w += 2; /* 1px padding on both sides */
|
||||
+ ret = x = m->ww - w;
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[LENGTH(colors)]);
|
||||
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
+ drw_rect(drw, x, 0, w, bh, 1, 1);
|
||||
+ x++;
|
||||
+
|
||||
+ /* process status text */
|
||||
+ i = -1;
|
||||
+ while (text[++i]) {
|
||||
+ if (text[i] == '^' && !isCode) {
|
||||
+ isCode = 1;
|
||||
+
|
||||
+ text[i] = '\0';
|
||||
+ w = TEXTW(text) - lrpad;
|
||||
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
+
|
||||
+ x += w;
|
||||
+
|
||||
+ /* process code */
|
||||
+ while (text[++i] != '^') {
|
||||
+ if (text[i] == 'c') {
|
||||
+ char buf[8];
|
||||
+ memcpy(buf, (char*)text+i+1, 7);
|
||||
+ buf[7] = '\0';
|
||||
+ drw_clr_create(drw, &drw->scheme[ColFg], buf);
|
||||
+ i += 7;
|
||||
+ } else if (text[i] == 'b') {
|
||||
+ char buf[8];
|
||||
+ memcpy(buf, (char*)text+i+1, 7);
|
||||
+ buf[7] = '\0';
|
||||
+ drw_clr_create(drw, &drw->scheme[ColBg], buf);
|
||||
+ i += 7;
|
||||
+ } else if (text[i] == 'd') {
|
||||
+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
+ drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
+ } else if (text[i] == 'r') {
|
||||
+ int rx = atoi(text + ++i);
|
||||
+ while (text[++i] != ',');
|
||||
+ int ry = atoi(text + ++i);
|
||||
+ while (text[++i] != ',');
|
||||
+ int rw = atoi(text + ++i);
|
||||
+ while (text[++i] != ',');
|
||||
+ int rh = atoi(text + ++i);
|
||||
+
|
||||
+ drw_rect(drw, rx + x, ry, rw, rh, 1, 0);
|
||||
+ } else if (text[i] == 'f') {
|
||||
+ x += atoi(text + ++i);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ text = text + i + 1;
|
||||
+ i=-1;
|
||||
+ isCode = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!isCode) {
|
||||
+ w = TEXTW(text) - lrpad;
|
||||
+ drw_text(drw, x, 0, w, bh, 0, text, 0);
|
||||
+ }
|
||||
+
|
||||
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
+ free(p);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
void
|
||||
drawbar(Monitor *m)
|
||||
{
|
||||
@@ -707,9 +816,7 @@ drawbar(Monitor *m)
|
||||
|
||||
/* 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]);
|
||||
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||
+ tw = m->ww - drawstatusbar(m, bh, stext);
|
||||
}
|
||||
|
||||
for (c = m->clients; c; c = c->next) {
|
||||
@@ -1571,7 +1678,8 @@ setup(void)
|
||||
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
|
||||
cursor[CurMove] = drw_cur_create(drw, XC_fleur);
|
||||
/* init appearance */
|
||||
- scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
|
||||
+ scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *));
|
||||
+ scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3);
|
||||
for (i = 0; i < LENGTH(colors); i++)
|
||||
scheme[i] = drw_scm_create(drw, colors[i], 3);
|
||||
/* init bars */
|
44
patches/functions/dwm-status2d-swap-save-restore-6.2.diff
Normal file
44
patches/functions/dwm-status2d-swap-save-restore-6.2.diff
Normal file
@ -0,0 +1,44 @@
|
||||
From dfd158c8dea87a0a4dbc5b2eda7c096069d1484a Mon Sep 17 00:00:00 2001
|
||||
From: tdu <tdukv@protonmail.com>
|
||||
Date: Wed, 26 Aug 2020 18:50:09 +0300
|
||||
Subject: [PATCH] Add the following tags for the status2d patch: ^w^ -
|
||||
Swaps bg/fg color. ^v^ - Saves the current fg/bg color. ^t^ - Restores
|
||||
the previously saved bg/fg color.
|
||||
|
||||
---
|
||||
dwm.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 931044f..de07b66 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -699,6 +699,7 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||
short isCode = 0;
|
||||
char *text;
|
||||
char *p;
|
||||
+ Clr oldbg, oldfg;
|
||||
|
||||
len = strlen(stext) + 1 ;
|
||||
if (!(text = (char*) malloc(sizeof(char)*len)))
|
||||
@@ -769,6 +770,17 @@ drawstatusbar(Monitor *m, int bh, char* stext) {
|
||||
} else if (text[i] == 'd') {
|
||||
drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
|
||||
drw->scheme[ColBg] = scheme[SchemeNorm][ColBg];
|
||||
+ } else if (text[i] == 'w') {
|
||||
+ Clr swp;
|
||||
+ swp = drw->scheme[ColFg];
|
||||
+ drw->scheme[ColFg] = drw->scheme[ColBg];
|
||||
+ drw->scheme[ColBg] = swp;
|
||||
+ } else if (text[i] == 'v') {
|
||||
+ oldfg = drw->scheme[ColFg];
|
||||
+ oldbg = drw->scheme[ColBg];
|
||||
+ } else if (text[i] == 't') {
|
||||
+ drw->scheme[ColFg] = oldfg;
|
||||
+ drw->scheme[ColBg] = oldbg;
|
||||
} else if (text[i] == 'r') {
|
||||
int rx = atoi(text + ++i);
|
||||
while (text[++i] != ',');
|
||||
--
|
||||
2.28.0
|
||||
|
Loading…
Reference in New Issue
Block a user