commit a34a5ee8921b5a74751f7ceb8aed807e76f4b4b9
parent 8e4c896a95eb81bcec270b20b6aa5f5c0b1aa5ef
Author: lhark <lhark@ntymail.com>
Date: Sun, 3 Nov 2019 13:38:45 -0500
[dwm][patch][status2d] Update patch for dwm 6.2
Diffstat:
3 files changed, 160 insertions(+), 160 deletions(-)
diff --git a/dwm.suckless.org/patches/status2d/dwm-status2d-20161231-bb3bd6f.diff b/dwm.suckless.org/patches/status2d/dwm-status2d-20161231-bb3bd6f.diff
@@ -1,158 +0,0 @@
-diff --git a/dwm.c b/dwm.c
-index d27cb67..464c9d6 100644
---- a/dwm.c
-+++ b/dwm.c
-@@ -163,6 +163,7 @@ static void detach(Client *c);
- static void detachstack(Client *c);
- static Monitor *dirtomon(int dir);
- static void drawbar(Monitor *m);
-+static int drawstatusbar(Monitor *m, int bh, char* text);
- static void drawbars(void);
- static void enternotify(XEvent *e);
- static void expose(XEvent *e);
-@@ -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 */
-@@ -483,7 +484,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);
-@@ -690,6 +691,106 @@ 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_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] == 'd') {
-+ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
-+ } 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)
- {
-@@ -701,9 +802,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]);
-- sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
-- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
-+ sw = m->ww - drawstatusbar(m, bh, stext);
- }
-
- for (c = m->clients; c; c = c->next) {
-@@ -1572,7 +1671,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(Scm));
-+ scheme = ecalloc(LENGTH(colors) + 1, sizeof(Scm));
-+ 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 */
diff --git a/dwm.suckless.org/patches/status2d/dwm-status2d-6.2.diff b/dwm.suckless.org/patches/status2d/dwm-status2d-6.2.diff
@@ -0,0 +1,158 @@
+diff --git a/dwm.c b/dwm.c
+index d27cb67..464c9d6 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -163,6 +163,7 @@ static void detach(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 */
+@@ -483,7 +484,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);
+@@ -690,6 +691,106 @@ 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_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] == 'd') {
++ drw->scheme[ColFg] = scheme[SchemeNorm][ColFg];
++ } 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)
+ {
+@@ -701,9 +802,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]);
+- sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
++ sw = m->ww - drawstatusbar(m, bh, stext);
+ }
+
+ for (c = m->clients; c; c = c->next) {
+@@ -1572,7 +1671,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 */
diff --git a/dwm.suckless.org/patches/status2d/index.md b/dwm.suckless.org/patches/status2d/index.md
@@ -11,7 +11,7 @@ an example of my status bar with multi-cpu and battery.
Download
--------
-* [dwm-status2d-20161231-bb3bd6f.diff](dwm-status2d-20161231-bb3bd6f.diff)
+* [dwm-status2d-6.2.diff](dwm-status2d-6.2.diff)
Usage
@@ -32,5 +32,5 @@ xsetroot -name "dwmstatus ^c#FF0000^ in red with red rectangle
Authors
-------
* [sipi](https://github.com/sipi)
-* lhark - <lhark@ntymail.com> (bb3bd6f port)
+* lhark - <lhark@ntymail.com> (6.2 port)