diff options
Diffstat (limited to 'dwm/patches')
| -rw-r--r-- | dwm/patches/dwm-status2d-20200508-60bb3df.diff | 180 | ||||
| -rw-r--r-- | dwm/patches/dwm-statuscolors-20181008-b69c870.diff | 94 |
2 files changed, 180 insertions, 94 deletions
diff --git a/dwm/patches/dwm-status2d-20200508-60bb3df.diff b/dwm/patches/dwm-status2d-20200508-60bb3df.diff new file mode 100644 index 0000000..6f353fd --- /dev/null +++ b/dwm/patches/dwm-status2d-20200508-60bb3df.diff | |||
| @@ -0,0 +1,180 @@ | |||
| 1 | From 60bb3dfaf91227eb02e828d74e6f4758b2c56542 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: cultab <rroarck@gmail.com> | ||
| 3 | Date: Fri, 8 May 2020 13:56:08 +0300 | ||
| 4 | Subject: [PATCH] fix status2d to work after ed3ab6 | ||
| 5 | |||
| 6 | ed3ab6 changed the name of the variable sw to tw, now the patch won't apply nor work. | ||
| 7 | This patch updates the variable name to the new one. | ||
| 8 | --- | ||
| 9 | dwm.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- | ||
| 10 | 1 file changed, 114 insertions(+), 6 deletions(-) | ||
| 11 | |||
| 12 | diff --git a/dwm.c b/dwm.c | ||
| 13 | index 9fd0286..71e18be 100644 | ||
| 14 | --- a/dwm.c | ||
| 15 | +++ b/dwm.c | ||
| 16 | @@ -163,6 +163,7 @@ static void detachstack(Client *c); | ||
| 17 | static Monitor *dirtomon(int dir); | ||
| 18 | static void drawbar(Monitor *m); | ||
| 19 | static void drawbars(void); | ||
| 20 | +static int drawstatusbar(Monitor *m, int bh, char* text); | ||
| 21 | static void enternotify(XEvent *e); | ||
| 22 | static void expose(XEvent *e); | ||
| 23 | static void focus(Client *c); | ||
| 24 | @@ -237,7 +238,7 @@ static void zoom(const Arg *arg); | ||
| 25 | |||
| 26 | /* variables */ | ||
| 27 | static const char broken[] = "broken"; | ||
| 28 | -static char stext[256]; | ||
| 29 | +static char stext[1024]; | ||
| 30 | static int screen; | ||
| 31 | static int sw, sh; /* X display screen geometry width, height */ | ||
| 32 | static int bh, blw = 0; /* bar geometry */ | ||
| 33 | @@ -485,7 +486,7 @@ cleanup(void) | ||
| 34 | cleanupmon(mons); | ||
| 35 | for (i = 0; i < CurLast; i++) | ||
| 36 | drw_cur_free(drw, cursor[i]); | ||
| 37 | - for (i = 0; i < LENGTH(colors); i++) | ||
| 38 | + for (i = 0; i < LENGTH(colors) + 1; i++) | ||
| 39 | free(scheme[i]); | ||
| 40 | XDestroyWindow(dpy, wmcheckwin); | ||
| 41 | drw_free(drw); | ||
| 42 | @@ -693,6 +694,114 @@ dirtomon(int dir) | ||
| 43 | return m; | ||
| 44 | } | ||
| 45 | |||
| 46 | +int | ||
| 47 | +drawstatusbar(Monitor *m, int bh, char* stext) { | ||
| 48 | + int ret, i, w, x, len; | ||
| 49 | + short isCode = 0; | ||
| 50 | + char *text; | ||
| 51 | + char *p; | ||
| 52 | + | ||
| 53 | + len = strlen(stext) + 1 ; | ||
| 54 | + if (!(text = (char*) malloc(sizeof(char)*len))) | ||
| 55 | + die("malloc"); | ||
| 56 | + p = text; | ||
| 57 | + memcpy(text, stext, len); | ||
| 58 | + | ||
| 59 | + /* compute width of the status text */ | ||
| 60 | + w = 0; | ||
| 61 | + i = -1; | ||
| 62 | + while (text[++i]) { | ||
| 63 | + if (text[i] == '^') { | ||
| 64 | + if (!isCode) { | ||
| 65 | + isCode = 1; | ||
| 66 | + text[i] = '\0'; | ||
| 67 | + w += TEXTW(text) - lrpad; | ||
| 68 | + text[i] = '^'; | ||
| 69 | + if (text[++i] == 'f') | ||
| 70 | + w += atoi(text + ++i); | ||
| 71 | + } else { | ||
| 72 | + isCode = 0; | ||
| 73 | + text = text + i + 1; | ||
| 74 | + i = -1; | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + if (!isCode) | ||
| 79 | + w += TEXTW(text) - lrpad; | ||
| 80 | + else | ||
| 81 | + isCode = 0; | ||
| 82 | + text = p; | ||
| 83 | + | ||
| 84 | + w += 2; /* 1px padding on both sides */ | ||
| 85 | + ret = x = m->ww - w; | ||
| 86 | + | ||
| 87 | + drw_setscheme(drw, scheme[LENGTH(colors)]); | ||
| 88 | + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; | ||
| 89 | + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; | ||
| 90 | + drw_rect(drw, x, 0, w, bh, 1, 1); | ||
| 91 | + x++; | ||
| 92 | + | ||
| 93 | + /* process status text */ | ||
| 94 | + i = -1; | ||
| 95 | + while (text[++i]) { | ||
| 96 | + if (text[i] == '^' && !isCode) { | ||
| 97 | + isCode = 1; | ||
| 98 | + | ||
| 99 | + text[i] = '\0'; | ||
| 100 | + w = TEXTW(text) - lrpad; | ||
| 101 | + drw_text(drw, x, 0, w, bh, 0, text, 0); | ||
| 102 | + | ||
| 103 | + x += w; | ||
| 104 | + | ||
| 105 | + /* process code */ | ||
| 106 | + while (text[++i] != '^') { | ||
| 107 | + if (text[i] == 'c') { | ||
| 108 | + char buf[8]; | ||
| 109 | + memcpy(buf, (char*)text+i+1, 7); | ||
| 110 | + buf[7] = '\0'; | ||
| 111 | + drw_clr_create(drw, &drw->scheme[ColFg], buf); | ||
| 112 | + i += 7; | ||
| 113 | + } else if (text[i] == 'b') { | ||
| 114 | + char buf[8]; | ||
| 115 | + memcpy(buf, (char*)text+i+1, 7); | ||
| 116 | + buf[7] = '\0'; | ||
| 117 | + drw_clr_create(drw, &drw->scheme[ColBg], buf); | ||
| 118 | + i += 7; | ||
| 119 | + } else if (text[i] == 'd') { | ||
| 120 | + drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; | ||
| 121 | + drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; | ||
| 122 | + } else if (text[i] == 'r') { | ||
| 123 | + int rx = atoi(text + ++i); | ||
| 124 | + while (text[++i] != ','); | ||
| 125 | + int ry = atoi(text + ++i); | ||
| 126 | + while (text[++i] != ','); | ||
| 127 | + int rw = atoi(text + ++i); | ||
| 128 | + while (text[++i] != ','); | ||
| 129 | + int rh = atoi(text + ++i); | ||
| 130 | + | ||
| 131 | + drw_rect(drw, rx + x, ry, rw, rh, 1, 0); | ||
| 132 | + } else if (text[i] == 'f') { | ||
| 133 | + x += atoi(text + ++i); | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + text = text + i + 1; | ||
| 138 | + i=-1; | ||
| 139 | + isCode = 0; | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + if (!isCode) { | ||
| 144 | + w = TEXTW(text) - lrpad; | ||
| 145 | + drw_text(drw, x, 0, w, bh, 0, text, 0); | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + drw_setscheme(drw, scheme[SchemeNorm]); | ||
| 149 | + free(p); | ||
| 150 | + | ||
| 151 | + return ret; | ||
| 152 | +} | ||
| 153 | + | ||
| 154 | void | ||
| 155 | drawbar(Monitor *m) | ||
| 156 | { | ||
| 157 | @@ -704,9 +813,7 @@ drawbar(Monitor *m) | ||
| 158 | |||
| 159 | /* draw status first so it can be overdrawn by tags later */ | ||
| 160 | if (m == selmon) { /* status is only drawn on selected monitor */ | ||
| 161 | - drw_setscheme(drw, scheme[SchemeNorm]); | ||
| 162 | - tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ | ||
| 163 | - drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); | ||
| 164 | + tw = m->ww - drawstatusbar(m, bh, stext); | ||
| 165 | } | ||
| 166 | |||
| 167 | for (c = m->clients; c; c = c->next) { | ||
| 168 | @@ -1568,7 +1675,8 @@ setup(void) | ||
| 169 | cursor[CurResize] = drw_cur_create(drw, XC_sizing); | ||
| 170 | cursor[CurMove] = drw_cur_create(drw, XC_fleur); | ||
| 171 | /* init appearance */ | ||
| 172 | - scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); | ||
| 173 | + scheme = ecalloc(LENGTH(colors) + 1, sizeof(Clr *)); | ||
| 174 | + scheme[LENGTH(colors)] = drw_scm_create(drw, colors[0], 3); | ||
| 175 | for (i = 0; i < LENGTH(colors); i++) | ||
| 176 | scheme[i] = drw_scm_create(drw, colors[i], 3); | ||
| 177 | /* init bars */ | ||
| 178 | -- | ||
| 179 | 2.26.2 | ||
| 180 | |||
diff --git a/dwm/patches/dwm-statuscolors-20181008-b69c870.diff b/dwm/patches/dwm-statuscolors-20181008-b69c870.diff deleted file mode 100644 index 8c7869a..0000000 --- a/dwm/patches/dwm-statuscolors-20181008-b69c870.diff +++ /dev/null | |||
| @@ -1,94 +0,0 @@ | |||
| 1 | From 35418d156fccb922710f6ca80a1f3972ba88b42f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Danny O'Brien <danny@spesh.com> | ||
| 3 | Date: Mon, 8 Oct 2018 19:21:29 -0700 | ||
| 4 | Subject: [PATCH] Add colors to status message in bar. | ||
| 5 | |||
| 6 | This patch matches the format used by | ||
| 7 | https://dwm.suckless.org/patches/statuscolors/ -- An \x01 character | ||
| 8 | switches to the normal foreground/color combo, \x02 switches to the | ||
| 9 | color combo used for selected tags, \03 is set by default to black on | ||
| 10 | yellow, \04 is white on red. | ||
| 11 | |||
| 12 | These color settings are defined in the colors array in config.def.h. | ||
| 13 | More can be added, but don't have more than 32, or you'll start hitting | ||
| 14 | real ASCII. | ||
| 15 | |||
| 16 | This applies cleanly on mainline dwm from commit 022d076 (Sat Jan 7 | ||
| 17 | 17:21:29 2017 +0100) until at least b69c870 (Sat Jun 2 17:15:42 2018 | ||
| 18 | +020). | ||
| 19 | |||
| 20 | --- | ||
| 21 | config.def.h | 13 ++++++++++--- | ||
| 22 | dwm.c | 18 ++++++++++++++++-- | ||
| 23 | 2 files changed, 26 insertions(+), 5 deletions(-) | ||
| 24 | |||
| 25 | diff --git a/config.def.h b/config.def.h | ||
| 26 | index 1c0b587..df92695 100644 | ||
| 27 | --- a/config.def.h | ||
| 28 | +++ b/config.def.h | ||
| 29 | @@ -12,10 +12,17 @@ static const char col_gray2[] = "#444444"; | ||
| 30 | static const char col_gray3[] = "#bbbbbb"; | ||
| 31 | static const char col_gray4[] = "#eeeeee"; | ||
| 32 | static const char col_cyan[] = "#005577"; | ||
| 33 | +static const char col_black[] = "#000000"; | ||
| 34 | +static const char col_red[] = "#ff0000"; | ||
| 35 | +static const char col_yellow[] = "#ffff00"; | ||
| 36 | +static const char col_white[] = "#ffffff"; | ||
| 37 | + | ||
| 38 | static const char *colors[][3] = { | ||
| 39 | - /* fg bg border */ | ||
| 40 | - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, | ||
| 41 | - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, | ||
| 42 | + /* fg bg border */ | ||
| 43 | + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, | ||
| 44 | + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, | ||
| 45 | + [SchemeWarn] = { col_black, col_yellow, col_red }, | ||
| 46 | + [SchemeUrgent]= { col_white, col_red, col_red }, | ||
| 47 | }; | ||
| 48 | |||
| 49 | /* tagging */ | ||
| 50 | diff --git a/dwm.c b/dwm.c | ||
| 51 | index 4465af1..9d9d46f 100644 | ||
| 52 | --- a/dwm.c | ||
| 53 | +++ b/dwm.c | ||
| 54 | @@ -59,7 +59,7 @@ | ||
| 55 | |||
| 56 | /* enums */ | ||
| 57 | enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ | ||
| 58 | -enum { SchemeNorm, SchemeSel }; /* color schemes */ | ||
| 59 | +enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent }; /* color schemes */ | ||
| 60 | enum { NetSupported, NetWMName, NetWMState, NetWMCheck, | ||
| 61 | NetWMFullscreen, NetActiveWindow, NetWMWindowType, | ||
| 62 | NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ | ||
| 63 | @@ -699,13 +699,27 @@ drawbar(Monitor *m) | ||
| 64 | int boxs = drw->fonts->h / 9; | ||
| 65 | int boxw = drw->fonts->h / 6 + 2; | ||
| 66 | unsigned int i, occ = 0, urg = 0; | ||
| 67 | + char *ts = stext; | ||
| 68 | + char *tp = stext; | ||
| 69 | + int tx = 0; | ||
| 70 | + char ctmp; | ||
| 71 | Client *c; | ||
| 72 | |||
| 73 | /* draw status first so it can be overdrawn by tags later */ | ||
| 74 | if (m == selmon) { /* status is only drawn on selected monitor */ | ||
| 75 | drw_setscheme(drw, scheme[SchemeNorm]); | ||
| 76 | sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ | ||
| 77 | - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); | ||
| 78 | + while (1) { | ||
| 79 | + if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; } | ||
| 80 | + ctmp = *ts; | ||
| 81 | + *ts = '\0'; | ||
| 82 | + drw_text(drw, m->ww - sw + tx, 0, sw - tx, bh, 0, tp, 0); | ||
| 83 | + tx += TEXTW(tp) -lrpad; | ||
| 84 | + if (ctmp == '\0') { break; } | ||
| 85 | + drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); | ||
| 86 | + *ts = ctmp; | ||
| 87 | + tp = ++ts; | ||
| 88 | + } | ||
| 89 | } | ||
| 90 | |||
| 91 | for (c = m->clients; c; c = c->next) { | ||
| 92 | -- | ||
| 93 | 2.19.1 | ||
| 94 | |||
