From 0460885e55b85c24985bd2dc7b4d853ae9a54e68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Czy=C5=BC?= Date: Fri, 24 Feb 2023 23:36:26 +0100 Subject: [PATCH] final patches --- dwm/.dwm/config.def.h | 34 ++ dwm/.dwm/config.def.h.orig | 11 +- dwm/.dwm/dwm.c | 183 ++++++++- dwm/.dwm/dwm.c.orig | 373 ++++++++++++++++-- dwm/.dwm/dwm.c.rej | 113 +----- ...-attachasideandbelow-20200702-f04cac6.diff | 100 ----- dwm/.dwm/patches/dwm-status2d-6.3.diff | 166 -------- dwm/.dwm/patches/dwm-status2d-xrdb-6.2.diff | 100 ----- 8 files changed, 577 insertions(+), 503 deletions(-) delete mode 100644 dwm/.dwm/patches/dwm-attachasideandbelow-20200702-f04cac6.diff delete mode 100644 dwm/.dwm/patches/dwm-status2d-6.3.diff delete mode 100644 dwm/.dwm/patches/dwm-status2d-xrdb-6.2.diff diff --git a/dwm/.dwm/config.def.h b/dwm/.dwm/config.def.h index be03226..c0258c0 100644 --- a/dwm/.dwm/config.def.h +++ b/dwm/.dwm/config.def.h @@ -21,6 +21,40 @@ static char normfgcolor[] = "#bbbbbb"; static char selfgcolor[] = "#eeeeee"; static char selbordercolor[] = "#005577"; static char selbgcolor[] = "#005577"; +static char termcol0[] = "#000000"; /* black */ +static char termcol1[] = "#ff0000"; /* red */ +static char termcol2[] = "#33ff00"; /* green */ +static char termcol3[] = "#ff0099"; /* yellow */ +static char termcol4[] = "#0066ff"; /* blue */ +static char termcol5[] = "#cc00ff"; /* magenta */ +static char termcol6[] = "#00ffff"; /* cyan */ +static char termcol7[] = "#d0d0d0"; /* white */ +static char termcol8[] = "#808080"; /* black */ +static char termcol9[] = "#ff0000"; /* red */ +static char termcol10[] = "#33ff00"; /* green */ +static char termcol11[] = "#ff0099"; /* yellow */ +static char termcol12[] = "#0066ff"; /* blue */ +static char termcol13[] = "#cc00ff"; /* magenta */ +static char termcol14[] = "#00ffff"; /* cyan */ +static char termcol15[] = "#ffffff"; /* white */ +static char *termcolor[] = { + termcol0, + termcol1, + termcol2, + termcol3, + termcol4, + termcol5, + termcol6, + termcol7, + termcol8, + termcol9, + termcol10, + termcol11, + termcol12, + termcol13, + termcol14, + termcol15, +}; static char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, diff --git a/dwm/.dwm/config.def.h.orig b/dwm/.dwm/config.def.h.orig index 833e343..be03226 100644 --- a/dwm/.dwm/config.def.h.orig +++ b/dwm/.dwm/config.def.h.orig @@ -25,6 +25,7 @@ static char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, + [SchemeHid] = { selbordercolor, normbgcolor, selbordercolor }, }; /* tagging */ @@ -82,8 +83,10 @@ static const Key keys[] = { { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_w, tabmode, {-1} }, - { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_j, focusstackvis, {.i = +1 } }, + { MODKEY, XK_k, focusstackvis, {.i = -1 } }, + { MODKEY|ShiftMask, XK_j, focusstackhid, {.i = +1 } }, + { MODKEY|ShiftMask, XK_k, focusstackhid, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, @@ -106,6 +109,9 @@ static const Key keys[] = { { MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_s, show, {0} }, + { MODKEY|ShiftMask, XK_s, showall, {0} }, + { MODKEY, XK_h, hide, {0} }, { MODKEY, XK_F5, xrdb, {.v = NULL } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) @@ -126,6 +132,7 @@ static const Button buttons[] = { /* click event mask button function argument */ { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button1, togglewin, {0} }, { ClkWinTitle, 0, Button2, zoom, {0} }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, diff --git a/dwm/.dwm/dwm.c b/dwm/.dwm/dwm.c index 467cda9..b05fe33 100644 --- a/dwm/.dwm/dwm.c +++ b/dwm/.dwm/dwm.c @@ -52,7 +52,8 @@ #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) -#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) +#define ISVISIBLEONTAG(C, T) ((C->tags & T)) +#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags]) #define HIDDEN(C) ((getstate(C->win) == IconicState)) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) @@ -178,6 +179,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac static void arrange(Monitor *m); static void arrangemon(Monitor *m); static void attach(Client *c); +static void attachBelow(Client *c); static void attachstack(Client *c); static void buttonpress(XEvent *e); static void compileregexes(void); @@ -197,6 +199,7 @@ static void drawbar(Monitor *m); static void drawbars(void); static void drawtab(Monitor *m); static void drawtabs(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); @@ -224,6 +227,7 @@ static void maprequest(XEvent *e); static void monocle(Monitor *m); static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); +static Client *nexttagged(Client *c); static Client *nexttiled(Client *c); static void pop(Client *c); static void propertynotify(XEvent *e); @@ -293,7 +297,7 @@ static const char autostartsh[] = "autostart.sh"; static const char broken[] = "broken"; static const char dwmdir[] = "dwm"; static const char localshare[] = ".local/share"; -static char stext[256]; +static char stext[1024]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh; /* bar height */ @@ -474,6 +478,27 @@ attach(Client *c) c->next = c->mon->clients; c->mon->clients = c; } +void +attachBelow(Client *c) +{ + //If there is nothing on the monitor or the selected client is floating, attach as normal + if(c->mon->sel == NULL || c->mon->sel->isfloating) { + Client *at = nexttagged(c); + if(!at) { + attach(c); + return; + } + c->next = at->next; + at->next = c; + return; + } + + //Set the new client's next property to the same as the currently selected clients next + c->next = c->mon->sel->next; + //Set the currently selected clients next property to the new client + c->mon->sel->next = c; + +} void attachstack(Client *c) @@ -587,7 +612,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); @@ -833,6 +858,120 @@ 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] == 'C') { + int c = atoi(text + ++i); + drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]); + } else if (text[i] == 'B') { + int c = atoi(text + ++i); + drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]); + } 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) { @@ -847,9 +986,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) { @@ -1389,6 +1526,22 @@ loadxrdb() XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); + XRDB_LOAD_COLOR("color0", termcol0); + XRDB_LOAD_COLOR("color1", termcol1); + XRDB_LOAD_COLOR("color2", termcol2); + XRDB_LOAD_COLOR("color3", termcol3); + XRDB_LOAD_COLOR("color4", termcol4); + XRDB_LOAD_COLOR("color5", termcol5); + XRDB_LOAD_COLOR("color6", termcol6); + XRDB_LOAD_COLOR("color7", termcol7); + XRDB_LOAD_COLOR("color8", termcol8); + XRDB_LOAD_COLOR("color9", termcol9); + XRDB_LOAD_COLOR("color10", termcol10); + XRDB_LOAD_COLOR("color11", termcol11); + XRDB_LOAD_COLOR("color12", termcol12); + XRDB_LOAD_COLOR("color13", termcol13); + XRDB_LOAD_COLOR("color14", termcol14); + XRDB_LOAD_COLOR("color15", termcol15); } } } @@ -1450,7 +1603,7 @@ manage(Window w, XWindowAttributes *wa) c->isfloating = c->oldstate = trans != None || c->isfixed; if (c->isfloating) XRaiseWindow(dpy, c->win); - attach(c); + attachBelow(c); attachstack(c); XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (unsigned char *) &(c->win), 1); @@ -1580,6 +1733,16 @@ movemouse(const Arg *arg) } } + Client * +nexttagged(Client *c) { + Client *walked = c->mon->clients; + for(; + walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags)); + walked = walked->next + ); + return walked; +} + Client * nexttiled(Client *c) { @@ -1920,7 +2083,7 @@ sendmon(Client *c, Monitor *m) detachstack(c); c->mon = m; c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ - attach(c); + attachBelow(c); attachstack(c); focus(NULL); arrange(NULL); @@ -2094,7 +2257,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 */ @@ -2543,6 +2707,7 @@ updategeom(void) detachstack(c); c->mon = mons; attach(c); + attachBelow(c); attachstack(c); } if (m == selmon) diff --git a/dwm/.dwm/dwm.c.orig b/dwm/.dwm/dwm.c.orig index a5d14bb..9c41ed1 100644 --- a/dwm/.dwm/dwm.c.orig +++ b/dwm/.dwm/dwm.c.orig @@ -53,6 +53,7 @@ #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) +#define HIDDEN(C) ((getstate(C->win) == IconicState)) #define LENGTH(X) (sizeof X / sizeof X[0]) #define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) @@ -77,7 +78,7 @@ /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -enum { SchemeNorm, SchemeSel }; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeHid }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMCheck, NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ @@ -138,6 +139,8 @@ struct Monitor { int nmaster; int num; int by; /* bar geometry */ + int btw; /* width of tasks portion of bar */ + int bt; /* number of tasks */ int ty; /* tab bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ @@ -148,6 +151,7 @@ struct Monitor { int showtab; int topbar; int toptab; + int hidsel; Client *clients; Client *sel; Client *stack; @@ -193,12 +197,15 @@ static void drawbar(Monitor *m); static void drawbars(void); static void drawtab(Monitor *m); static void drawtabs(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); static void focusin(XEvent *e); static void focusmon(const Arg *arg); -static void focusstack(const Arg *arg); +static void focusstackvis(const Arg *arg); +static void focusstackhid(const Arg *arg); +static void focusstack(int inc, int vis); static void focuswin(const Arg* arg); static Atom getatomprop(Client *c, Atom prop); static int getrootptr(int *x, int *y); @@ -206,6 +213,8 @@ static long getstate(Window w); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void grabkeys(void); +static void hide(const Arg *arg); +static void hidewin(Client *c); static void incnmaster(const Arg *arg); static void keypress(XEvent *e); static void killclient(const Arg *arg); @@ -238,6 +247,9 @@ static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); +static void show(const Arg *arg); +static void showall(const Arg *arg); +static void showwin(Client *c); static void showhide(Client *c); static void sighup(int unused); static void sigterm(int unused); @@ -251,6 +263,7 @@ static void togglefloating(const Arg *arg); static void togglescratch(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); +static void togglewin(const Arg *arg); static void unfocus(Client *c, int setfocus); static void unmanage(Client *c, int destroyed); static void unmapnotify(XEvent *e); @@ -281,7 +294,7 @@ static const char autostartsh[] = "autostart.sh"; static const char broken[] = "broken"; static const char dwmdir[] = "dwm"; static const char localshare[] = ".local/share"; -static char stext[256]; +static char stext[1024]; static int screen; static int sw, sh; /* X display screen geometry width, height */ static int bh; /* bar height */ @@ -473,6 +486,7 @@ attachstack(Client *c) void buttonpress(XEvent *e) { + int blw = TEXTW(selmon->ltsymbol); unsigned int i, x, click; Arg arg = {0}; Client *c; @@ -496,10 +510,25 @@ buttonpress(XEvent *e) arg.ui = 1 << i; } else if (ev->x < x + TEXTW(selmon->ltsymbol)) click = ClkLtSymbol; - else if (ev->x > selmon->ww - (int)TEXTW(stext)) + /* 2px right padding */ + else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2) click = ClkStatusText; - else - click = ClkWinTitle; + else { + x += blw; + c = m->clients; + + if (c) { + do { + if (!ISVISIBLE(c)) + continue; + else + x +=(1.0 / (double)m->bt) * m->btw; + } while (ev->x > x && (c = c->next)); + + click = ClkWinTitle; + arg.v = c; + } + } } if(ev->window == selmon->tabwin) { i = 0; x = 0; @@ -526,7 +555,7 @@ buttonpress(XEvent *e) for (i = 0; i < LENGTH(buttons); i++) if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)){ - buttons[i].func(((click == ClkTagBar || click == ClkTabBar) && buttons[i].arg.i == 0) ? &arg : &buttons[i].arg); + buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); } } @@ -559,7 +588,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); @@ -805,10 +834,124 @@ 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] == 'C') { + int c = atoi(text + ++i); + drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]); + } else if (text[i] == 'B') { + int c = atoi(text + ++i); + drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]); + } 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) { - int x, w, tw = 0; + int x, w, tw = 0, n = 0, scm; int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; @@ -819,12 +962,12 @@ 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) { + if (ISVISIBLE(c)) + n++; occ |= c->tags; if (c->isurgent) urg |= c->tags; @@ -845,16 +988,36 @@ drawbar(Monitor *m) x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); if ((w = m->ww - tw - x) > bh) { - if (m->sel) { - drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); - if (m->sel->isfloating) - drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); + if (n > 0) { + int remainder = w % n; + int tabw = (1.0 / (double)n) * w + 1; + for (c = m->clients; c; c = c->next) { + if (!ISVISIBLE(c)) + continue; + if (m->sel == c) + scm = SchemeSel; + else if (HIDDEN(c)) + scm = SchemeHid; + else + scm = SchemeNorm; + drw_setscheme(drw, scheme[scm]); + + if (remainder >= 0) { + if (remainder == 0) { + tabw--; + } + remainder--; + } + drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0); + x += tabw; + } } else { drw_setscheme(drw, scheme[SchemeNorm]); drw_rect(drw, x, 0, w, bh, 1, 1); } } + m->bt = n; + m->btw = w; drw_map(drw, m->barwin, 0, 0, m->ww, bh); } @@ -1001,9 +1164,17 @@ void focus(Client *c) { if (!c || !ISVISIBLE(c)) - for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); - if (selmon->sel && selmon->sel != c) + for (c = selmon->stack; c && (!ISVISIBLE(c) || HIDDEN(c)); c = c->snext); + if (selmon->sel && selmon->sel != c) { unfocus(selmon->sel, 0); + + if (selmon->hidsel) { + hidewin(selmon->sel); + if (c) + arrange(c->mon); + selmon->hidsel = 0; + } + } if (c) { if (c->mon != selmon) selmon = c->mon; @@ -1048,28 +1219,52 @@ focusmon(const Arg *arg) } void -focusstack(const Arg *arg) +focusstackvis(const Arg *arg) { + focusstack(arg->i, 0); +} + +void +focusstackhid(const Arg *arg) { + focusstack(arg->i, 1); +} + +void +focusstack(int inc, int hid) { Client *c = NULL, *i; - - if (!selmon->sel || (selmon->sel->isfullscreen && lockfullscreen)) + // if no client selected AND exclude hidden client; if client selected but fullscreened + if ((!selmon->sel && !hid) || (selmon->sel && selmon->sel->isfullscreen && lockfullscreen)) return; - if (arg->i > 0) { - for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next); + if (!selmon->clients) + return; + if (inc > 0) { + if (selmon->sel) + for (c = selmon->sel->next; + c && (!ISVISIBLE(c) || (!hid && HIDDEN(c))); + c = c->next); if (!c) - for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next); + for (c = selmon->clients; + c && (!ISVISIBLE(c) || (!hid && HIDDEN(c))); + c = c->next); } else { - for (i = selmon->clients; i != selmon->sel; i = i->next) - if (ISVISIBLE(i)) - c = i; + if (selmon->sel) { + for (i = selmon->clients; i != selmon->sel; i = i->next) + if (ISVISIBLE(i) && !(!hid && HIDDEN(i))) + c = i; + } else + c = selmon->clients; if (!c) for (; i; i = i->next) - if (ISVISIBLE(i)) + if (ISVISIBLE(i) && !(!hid && HIDDEN(i))) c = i; } if (c) { focus(c); restack(selmon); + if (HIDDEN(c)) { + showwin(c); + c->mon->hidsel = 1; + } } } @@ -1202,6 +1397,36 @@ grabkeys(void) } } +void +hide(const Arg *arg) +{ + hidewin(selmon->sel); + focus(NULL); + arrange(selmon); +} + +void +hidewin(Client *c) { + if (!c || HIDDEN(c)) + return; + + Window w = c->win; + static XWindowAttributes ra, ca; + + // more or less taken directly from blackbox's hide() function + XGrabServer(dpy); + XGetWindowAttributes(dpy, root, &ra); + XGetWindowAttributes(dpy, w, &ca); + // prevent UnmapNotify events + XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); + XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); + XUnmapWindow(dpy, w); + setclientstate(c, IconicState); + XSelectInput(dpy, root, ra.your_event_mask); + XSelectInput(dpy, w, ca.your_event_mask); + XUngrabServer(dpy); +} + void incnmaster(const Arg *arg) { @@ -1277,6 +1502,22 @@ loadxrdb() XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); + XRDB_LOAD_COLOR("color0", termcol0); + XRDB_LOAD_COLOR("color1", termcol1); + XRDB_LOAD_COLOR("color2", termcol2); + XRDB_LOAD_COLOR("color3", termcol3); + XRDB_LOAD_COLOR("color4", termcol4); + XRDB_LOAD_COLOR("color5", termcol5); + XRDB_LOAD_COLOR("color6", termcol6); + XRDB_LOAD_COLOR("color7", termcol7); + XRDB_LOAD_COLOR("color8", termcol8); + XRDB_LOAD_COLOR("color9", termcol9); + XRDB_LOAD_COLOR("color10", termcol10); + XRDB_LOAD_COLOR("color11", termcol11); + XRDB_LOAD_COLOR("color12", termcol12); + XRDB_LOAD_COLOR("color13", termcol13); + XRDB_LOAD_COLOR("color14", termcol14); + XRDB_LOAD_COLOR("color15", termcol15); } } } @@ -1343,12 +1584,14 @@ manage(Window w, XWindowAttributes *wa) XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, (unsigned char *) &(c->win), 1); XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ - setclientstate(c, NormalState); + if (!HIDDEN(c)) + setclientstate(c, NormalState); if (c->mon == selmon) unfocus(selmon->sel, 0); c->mon->sel = c; arrange(c->mon); - XMapWindow(dpy, c->win); + if (!HIDDEN(c)) + XMapWindow(dpy, c->win); focus(NULL); } @@ -1469,7 +1712,7 @@ movemouse(const Arg *arg) Client * nexttiled(Client *c) { - for (; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); + for (; c && (c->isfloating || !ISVISIBLE(c) || HIDDEN(c)); c = c->next); return c; } @@ -1525,6 +1768,16 @@ void quit(const Arg *arg) { if(arg->i) restart = 1; + // fix: reloading dwm keeps all the hidden clients hidden + Monitor *m; + Client *c; + for (m = mons; m; m = m->next) { + if (m) { + for (c = m->stack; c; c = c->next) + if (c && HIDDEN(c)) showwin(c); + } + } + running = 0; } @@ -1970,7 +2223,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 */ @@ -2012,6 +2266,42 @@ seturgent(Client *c, int urg) XFree(wmh); } +void +show(const Arg *arg) +{ + if (selmon->hidsel) + selmon->hidsel = 0; + showwin(selmon->sel); +} + +void +showall(const Arg *arg) +{ + Client *c = NULL; + selmon->hidsel = 0; + for (c = selmon->clients; c; c = c->next) { + if (ISVISIBLE(c)) + showwin(c); + } + if (!selmon->sel) { + for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next); + if (c) + focus(c); + } + restack(selmon); +} + +void +showwin(Client *c) +{ + if (!c || !HIDDEN(c)) + return; + + XMapWindow(dpy, c->win); + setclientstate(c, NormalState); + arrange(c->mon); +} + void showhide(Client *c) { @@ -2188,6 +2478,23 @@ toggleview(const Arg *arg) } } +void +togglewin(const Arg *arg) +{ + Client *c = (Client*)arg->v; + + if (c == selmon->sel) { + hidewin(c); + focus(NULL); + arrange(c->mon); + } else { + if (HIDDEN(c)) + showwin(c); + focus(c); + restack(selmon); + } +} + void unfocus(Client *c, int setfocus) { diff --git a/dwm/.dwm/dwm.c.rej b/dwm/.dwm/dwm.c.rej index 53b2d31..bf11ffa 100644 --- a/dwm/.dwm/dwm.c.rej +++ b/dwm/.dwm/dwm.c.rej @@ -1,93 +1,20 @@ ---- dwm.c -+++ dwm.c -@@ -118,6 +119,8 @@ struct Monitor { - int nmaster; - int num; - int by; /* bar geometry */ -+ int btw; /* width of tasks portion of bar */ -+ int bt; /* number of tasks */ - int mx, my, mw, mh; /* screen size */ - int wx, wy, ww, wh; /* window area */ - unsigned int seltags; -@@ -125,6 +128,7 @@ struct Monitor { - unsigned int tagset[2]; - int showbar; - int topbar; -+ int hidsel; - Client *clients; - Client *sel; - Client *stack; -@@ -169,13 +173,17 @@ static void expose(XEvent *e); - static void focus(Client *c); - static void focusin(XEvent *e); - static void focusmon(const Arg *arg); --static void focusstack(const Arg *arg); -+static void focusstackvis(const Arg *arg); -+static void focusstackhid(const Arg *arg); -+static void focusstack(int inc, int vis); - static Atom getatomprop(Client *c, Atom prop); - static int getrootptr(int *x, int *y); - static long getstate(Window w); - static int gettextprop(Window w, Atom atom, char *text, unsigned int size); - static void grabbuttons(Client *c, int focused); - static void grabkeys(void); -+static void hide(const Arg *arg); -+static void hidewin(Client *c); - static void incnmaster(const Arg *arg); - static void keypress(XEvent *e); - static void killclient(const Arg *arg); -@@ -445,10 +457,25 @@ buttonpress(XEvent *e) - arg.ui = 1 << i; - } else if (ev->x < x + blw) - click = ClkLtSymbol; -- else if (ev->x > selmon->ww - (int)TEXTW(stext)) -+ /* 2px right padding */ -+ else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - 2) - click = ClkStatusText; -- else -- click = ClkWinTitle; -+ else { -+ x += blw; -+ c = m->clients; -+ -+ if (c) { -+ do { -+ if (!ISVISIBLE(c)) -+ continue; -+ else -+ x +=(1.0 / (double)m->bt) * m->btw; -+ } while (ev->x > x && (c = c->next)); -+ -+ click = ClkWinTitle; -+ arg.v = c; -+ } -+ } - } else if ((c = wintoclient(ev->window))) { - focus(c); - restack(selmon); -@@ -458,7 +485,7 @@ buttonpress(XEvent *e) - for (i = 0; i < LENGTH(buttons); i++) - if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button - && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) -- buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); -+ buttons[i].func((click == ClkTagBar || click == ClkWinTitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); - } - - void -@@ -1343,6 +1456,16 @@ propertynotify(XEvent *e) - void - quit(const Arg *arg) - { -+ // fix: reloading dwm keeps all the hidden clients hidden -+ Monitor *m; -+ Client *c; -+ for (m = mons; m; m = m->next) { -+ if (m) { -+ for (c = m->stack; c; c = c->next) -+ if (c && HIDDEN(c)) showwin(c); -+ } -+ } -+ - running = 0; - } - +--- dwm.c 2020-07-05 16:05:02.555947738 -0300 ++++ dwm.c 2020-07-05 16:06:19.592609932 -0300 +@@ -49,7 +49,8 @@ + #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) + #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ + * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) +-#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) ++#define ISVISIBLEONTAG(C, T) ((C->tags & T)) ++#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags]) + #define LENGTH(X) (sizeof X / sizeof X[0]) + #define MOUSEMASK (BUTTONMASK|PointerMotionMask) + #define WIDTH(X) ((X)->w + 2 * (X)->bw) +@@ -1934,6 +1968,7 @@ updategeom(void) + detachstack(c); + c->mon = mons; + attach(c); ++ attachBelow(c); + attachstack(c); + } + if (m == selmon) diff --git a/dwm/.dwm/patches/dwm-attachasideandbelow-20200702-f04cac6.diff b/dwm/.dwm/patches/dwm-attachasideandbelow-20200702-f04cac6.diff deleted file mode 100644 index 1b9219d..0000000 --- a/dwm/.dwm/patches/dwm-attachasideandbelow-20200702-f04cac6.diff +++ /dev/null @@ -1,100 +0,0 @@ -diff -up b/dwm.c a/dwm.c ---- b/dwm.c 2020-07-05 16:05:02.555947738 -0300 -+++ a/dwm.c 2020-07-05 16:06:19.592609932 -0300 -@@ -49,7 +49,8 @@ - #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) - #define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \ - * MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy))) --#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) -+#define ISVISIBLEONTAG(C, T) ((C->tags & T)) -+#define ISVISIBLE(C) ISVISIBLEONTAG(C, C->mon->tagset[C->mon->seltags]) - #define LENGTH(X) (sizeof X / sizeof X[0]) - #define MOUSEMASK (BUTTONMASK|PointerMotionMask) - #define WIDTH(X) ((X)->w + 2 * (X)->bw) -@@ -147,6 +148,7 @@ static int applysizehints(Client *c, int - static void arrange(Monitor *m); - static void arrangemon(Monitor *m); - static void attach(Client *c); -+static void attachBelow(Client *c); - static void attachstack(Client *c); - static void buttonpress(XEvent *e); - static void checkotherwm(void); -@@ -184,6 +186,7 @@ static void maprequest(XEvent *e); - static void monocle(Monitor *m); - static void motionnotify(XEvent *e); - static void movemouse(const Arg *arg); -+static Client *nexttagged(Client *c); - static Client *nexttiled(Client *c); - static void pop(Client *); - static void propertynotify(XEvent *e); -@@ -406,6 +409,27 @@ attach(Client *c) - c->next = c->mon->clients; - c->mon->clients = c; - } -+void -+attachBelow(Client *c) -+{ -+ //If there is nothing on the monitor or the selected client is floating, attach as normal -+ if(c->mon->sel == NULL || c->mon->sel->isfloating) { -+ Client *at = nexttagged(c); -+ if(!at) { -+ attach(c); -+ return; -+ } -+ c->next = at->next; -+ at->next = c; -+ return; -+ } -+ -+ //Set the new client's next property to the same as the currently selected clients next -+ c->next = c->mon->sel->next; -+ //Set the currently selected clients next property to the new client -+ c->mon->sel->next = c; -+ -+} - - void - attachstack(Client *c) -@@ -1063,7 +1087,7 @@ manage(Window w, XWindowAttributes *wa) - c->isfloating = c->oldstate = trans != None || c->isfixed; - if (c->isfloating) - XRaiseWindow(dpy, c->win); -- attach(c); -+ attachBelow(c); - attachstack(c); - XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, - (unsigned char *) &(c->win), 1); -@@ -1193,6 +1217,16 @@ movemouse(const Arg *arg) - } - } - -+ Client * -+nexttagged(Client *c) { -+ Client *walked = c->mon->clients; -+ for(; -+ walked && (walked->isfloating || !ISVISIBLEONTAG(walked, c->tags)); -+ walked = walked->next -+ ); -+ return walked; -+} -+ - Client * - nexttiled(Client *c) - { -@@ -1418,7 +1452,7 @@ sendmon(Client *c, Monitor *m) - detachstack(c); - c->mon = m; - c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ -- attach(c); -+ attachBelow(c); - attachstack(c); - focus(NULL); - arrange(NULL); -@@ -1901,6 +1935,7 @@ updategeom(void) - detachstack(c); - c->mon = mons; - attach(c); -+ attachBelow(c); - attachstack(c); - } - if (m == selmon) diff --git a/dwm/.dwm/patches/dwm-status2d-6.3.diff b/dwm/.dwm/patches/dwm-status2d-6.3.diff deleted file mode 100644 index 52bf58d..0000000 --- a/dwm/.dwm/patches/dwm-status2d-6.3.diff +++ /dev/null @@ -1,166 +0,0 @@ -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 */ diff --git a/dwm/.dwm/patches/dwm-status2d-xrdb-6.2.diff b/dwm/.dwm/patches/dwm-status2d-xrdb-6.2.diff deleted file mode 100644 index 1f22aa5..0000000 --- a/dwm/.dwm/patches/dwm-status2d-xrdb-6.2.diff +++ /dev/null @@ -1,100 +0,0 @@ -From bd7dd6d06e8b8c9dd6b595b2ce5f6e88b9565311 Mon Sep 17 00:00:00 2001 -From: tdu -Date: Wed, 26 Aug 2020 21:26:21 +0300 -Subject: [PATCH] Use the 16 terminal colors from xrdb for status2d. - -^C^ - fg. -^B^ - bg. ---- - config.def.h | 34 ++++++++++++++++++++++++++++++++++ - dwm.c | 22 ++++++++++++++++++++++ - 2 files changed, 56 insertions(+) - -diff --git a/config.def.h b/config.def.h -index 5db7d05..46bc6fe 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -13,6 +13,40 @@ static char normfgcolor[] = "#bbbbbb"; - static char selfgcolor[] = "#eeeeee"; - static char selbordercolor[] = "#005577"; - static char selbgcolor[] = "#005577"; -+static char termcol0[] = "#000000"; /* black */ -+static char termcol1[] = "#ff0000"; /* red */ -+static char termcol2[] = "#33ff00"; /* green */ -+static char termcol3[] = "#ff0099"; /* yellow */ -+static char termcol4[] = "#0066ff"; /* blue */ -+static char termcol5[] = "#cc00ff"; /* magenta */ -+static char termcol6[] = "#00ffff"; /* cyan */ -+static char termcol7[] = "#d0d0d0"; /* white */ -+static char termcol8[] = "#808080"; /* black */ -+static char termcol9[] = "#ff0000"; /* red */ -+static char termcol10[] = "#33ff00"; /* green */ -+static char termcol11[] = "#ff0099"; /* yellow */ -+static char termcol12[] = "#0066ff"; /* blue */ -+static char termcol13[] = "#cc00ff"; /* magenta */ -+static char termcol14[] = "#00ffff"; /* cyan */ -+static char termcol15[] = "#ffffff"; /* white */ -+static char *termcolor[] = { -+ termcol0, -+ termcol1, -+ termcol2, -+ termcol3, -+ termcol4, -+ termcol5, -+ termcol6, -+ termcol7, -+ termcol8, -+ termcol9, -+ termcol10, -+ termcol11, -+ termcol12, -+ termcol13, -+ termcol14, -+ termcol15, -+}; - static char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, -diff --git a/dwm.c b/dwm.c -index 87547f0..601dc1d 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -784,6 +784,12 @@ drawstatusbar(Monitor *m, int bh, char* stext) { - buf[7] = '\0'; - drw_clr_create(drw, &drw->scheme[ColBg], buf); - i += 7; -+ } else if (text[i] == 'C') { -+ int c = atoi(text + ++i); -+ drw_clr_create(drw, &drw->scheme[ColFg], termcolor[c]); -+ } else if (text[i] == 'B') { -+ int c = atoi(text + ++i); -+ drw_clr_create(drw, &drw->scheme[ColBg], termcolor[c]); - } else if (text[i] == 'd') { - drw->scheme[ColFg] = scheme[SchemeNorm][ColFg]; - drw->scheme[ColBg] = scheme[SchemeNorm][ColBg]; -@@ -1163,6 +1169,22 @@ loadxrdb() - XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); - XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); - XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); -+ XRDB_LOAD_COLOR("color0", termcol0); -+ XRDB_LOAD_COLOR("color1", termcol1); -+ XRDB_LOAD_COLOR("color2", termcol2); -+ XRDB_LOAD_COLOR("color3", termcol3); -+ XRDB_LOAD_COLOR("color4", termcol4); -+ XRDB_LOAD_COLOR("color5", termcol5); -+ XRDB_LOAD_COLOR("color6", termcol6); -+ XRDB_LOAD_COLOR("color7", termcol7); -+ XRDB_LOAD_COLOR("color8", termcol8); -+ XRDB_LOAD_COLOR("color9", termcol9); -+ XRDB_LOAD_COLOR("color10", termcol10); -+ XRDB_LOAD_COLOR("color11", termcol11); -+ XRDB_LOAD_COLOR("color12", termcol12); -+ XRDB_LOAD_COLOR("color13", termcol13); -+ XRDB_LOAD_COLOR("color14", termcol14); -+ XRDB_LOAD_COLOR("color15", termcol15); - } - } - } --- -2.28.0 -