diff --git a/dwm/.dwm/config.def.h b/dwm/.dwm/config.def.h index f52d038..378e25e 100644 --- a/dwm/.dwm/config.def.h +++ b/dwm/.dwm/config.def.h @@ -47,6 +47,8 @@ static const Layout layouts[] = { { "><>", NULL }, /* no layout function means floating behavior */ { "[M]", monocle }, { "HHH", grid }, + { "TTT", bstack }, + { "===", bstackhoriz }, }; /* key definitions */ @@ -86,6 +88,8 @@ static const Key keys[] = { { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_g, setlayout, {.v = &layouts[3]} }, + { MODKEY, XK_u, setlayout, {.v = &layouts[4]} }, + { MODKEY, XK_o, setlayout, {.v = &layouts[5]} }, { MODKEY|ShiftMask, XK_f, fullscreen, {0} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, diff --git a/dwm/.dwm/config.def.h.orig b/dwm/.dwm/config.def.h.orig index 1a0dfae..f52d038 100644 --- a/dwm/.dwm/config.def.h.orig +++ b/dwm/.dwm/config.def.h.orig @@ -9,15 +9,16 @@ static const int topbar = 1; /* 0 means bottom bar */ static const int user_bh = 0; /* 0 means that dwm will calculate bar height, >= 1 means dwm will user_bh as bar height */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; -static const char col_gray1[] = "#222222"; -static const char col_gray2[] = "#444444"; -static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#005577"; -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +static char normbgcolor[] = "#222222"; +static char normbordercolor[] = "#444444"; +static char normfgcolor[] = "#bbbbbb"; +static char selfgcolor[] = "#eeeeee"; +static char selbordercolor[] = "#005577"; +static char selbgcolor[] = "#005577"; +static char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, + [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, }; /* tagging */ @@ -61,7 +62,7 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL }; static const char *termcmd[] = { "alacritty", NULL }; static const char scratchpadname[] = "scratchpad"; static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; @@ -94,6 +95,7 @@ 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_F5, xrdb, {.v = NULL } }, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) diff --git a/dwm/.dwm/config.def.h.rej b/dwm/.dwm/config.def.h.rej index a96e571..69c0678 100644 --- a/dwm/.dwm/config.def.h.rej +++ b/dwm/.dwm/config.def.h.rej @@ -1,11 +1,20 @@ --- config.def.h +++ config.def.h -@@ -57,7 +58,7 @@ static const Layout layouts[] = { +@@ -41,6 +41,8 @@ static const Layout layouts[] = { + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, ++ { "TTT", bstack }, ++ { "===", bstackhoriz }, + }; - /* commands */ - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ --static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL }; - static const char *termcmd[] = { "st", NULL }; - - static Key keys[] = { + /* key definitions */ +@@ -76,6 +78,8 @@ static Key keys[] = { + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, ++ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} }, ++ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/dwm/.dwm/dwm.c b/dwm/.dwm/dwm.c index 8f4dc06..f9dafdd 100644 --- a/dwm/.dwm/dwm.c +++ b/dwm/.dwm/dwm.c @@ -260,6 +260,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void xrdb(const Arg *arg); static void zoom(const Arg *arg); +static void bstack(Monitor *m); +static void bstackhoriz(Monitor *m); /* variables */ static const char autostartblocksh[] = "autostart_blocking.sh"; @@ -2436,3 +2438,65 @@ main(int argc, char *argv[]) XCloseDisplay(dpy); return EXIT_SUCCESS; } + +static void +bstack(Monitor *m) { + int w, h, mh, mx, tx, ty, tw; + unsigned int i, n; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + tw = m->ww / (n - m->nmaster); + ty = m->wy + mh; + } else { + mh = m->wh; + tw = m->ww; + ty = m->wy; + } + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += WIDTH(c); + } else { + h = m->wh - mh; + resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); + if (tw != m->ww) + tx += WIDTH(c); + } + } +} + +static void +bstackhoriz(Monitor *m) { + int w, mh, mx, tx, ty, th; + unsigned int i, n; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + if (n > m->nmaster) { + mh = m->nmaster ? m->mfact * m->wh : 0; + th = (m->wh - mh) / (n - m->nmaster); + ty = m->wy + mh; + } else { + th = mh = m->wh; + ty = m->wy; + } + for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + w = (m->ww - mx) / (MIN(n, m->nmaster) - i); + resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); + mx += WIDTH(c); + } else { + resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); + if (th != m->wh) + ty += HEIGHT(c); + } + } +} diff --git a/dwm/.dwm/dwm.c.orig b/dwm/.dwm/dwm.c.orig index 07ebd1a..8f4dc06 100644 --- a/dwm/.dwm/dwm.c.orig +++ b/dwm/.dwm/dwm.c.orig @@ -37,6 +37,7 @@ #include #include #include +#include #include #ifdef XINERAMA #include @@ -58,6 +59,21 @@ #define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) +#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \ + if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \ + int i = 1; \ + for (; i <= 6; i++) { \ + if (value.addr[i] < 48) break; \ + if (value.addr[i] > 57 && value.addr[i] < 65) break; \ + if (value.addr[i] > 70 && value.addr[i] < 97) break; \ + if (value.addr[i] > 102) break; \ + } \ + if (i == 7) { \ + strncpy(V, value.addr, 7); \ + V[7] = '\0'; \ + } \ + } \ + } /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ @@ -182,6 +198,7 @@ static void grabkeys(void); static void incnmaster(const Arg *arg); static void keypress(XEvent *e); static void killclient(const Arg *arg); +static void loadxrdb(void); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); @@ -241,6 +258,7 @@ static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); +static void xrdb(const Arg *arg); static void zoom(const Arg *arg); /* variables */ @@ -1081,6 +1099,37 @@ killclient(const Arg *arg) } } +void +loadxrdb() +{ + Display *display; + char * resm; + XrmDatabase xrdb; + char *type; + XrmValue value; + + display = XOpenDisplay(NULL); + + if (display != NULL) { + resm = XResourceManagerString(display); + + if (resm != NULL) { + xrdb = XrmGetStringDatabase(resm); + + if (xrdb != NULL) { + XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor); + XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor); + XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor); + XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); + XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); + XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); + } + } + } + + XCloseDisplay(display); +} + void manage(Window w, XWindowAttributes *wa) { @@ -2336,6 +2385,17 @@ xerrorstart(Display *dpy, XErrorEvent *ee) return -1; } +void +xrdb(const Arg *arg) +{ + loadxrdb(); + int i; + for (i = 0; i < LENGTH(colors); i++) + scheme[i] = drw_scm_create(drw, colors[i], 3); + focus(NULL); + arrange(NULL); +} + void zoom(const Arg *arg) { @@ -2361,6 +2421,8 @@ main(int argc, char *argv[]) die("dwm: cannot open display"); compileregexes(); checkotherwm(); + XrmInitialize(); + loadxrdb(); setup(); #ifdef __OpenBSD__ if (pledge("stdio rpath proc exec", NULL) == -1) diff --git a/dwm/.dwm/patches/dwm-bottomstack-20160719-56a31dc.diff b/dwm/.dwm/patches/dwm-bottomstack-20160719-56a31dc.diff deleted file mode 100644 index d982817..0000000 --- a/dwm/.dwm/patches/dwm-bottomstack-20160719-56a31dc.diff +++ /dev/null @@ -1,101 +0,0 @@ -diff --git a/config.def.h b/config.def.h -index fd77a07..c3a044b 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -41,6 +41,8 @@ static const Layout layouts[] = { - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, -+ { "TTT", bstack }, -+ { "===", bstackhoriz }, - }; - - /* key definitions */ -@@ -76,6 +78,8 @@ static Key keys[] = { - { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, -+ { MODKEY, XK_u, setlayout, {.v = &layouts[3]} }, -+ { MODKEY, XK_o, setlayout, {.v = &layouts[4]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, -diff --git a/dwm.c b/dwm.c -index b2bc9bd..8b74165 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -234,6 +234,8 @@ static int xerror(Display *dpy, XErrorEvent *ee); - static int xerrordummy(Display *dpy, XErrorEvent *ee); - static int xerrorstart(Display *dpy, XErrorEvent *ee); - static void zoom(const Arg *arg); -+static void bstack(Monitor *m); -+static void bstackhoriz(Monitor *m); - - /* variables */ - static const char broken[] = "broken"; -@@ -2138,3 +2140,65 @@ main(int argc, char *argv[]) - XCloseDisplay(dpy); - return EXIT_SUCCESS; - } -+ -+static void -+bstack(Monitor *m) { -+ int w, h, mh, mx, tx, ty, tw; -+ unsigned int i, n; -+ Client *c; -+ -+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); -+ if (n == 0) -+ return; -+ if (n > m->nmaster) { -+ mh = m->nmaster ? m->mfact * m->wh : 0; -+ tw = m->ww / (n - m->nmaster); -+ ty = m->wy + mh; -+ } else { -+ mh = m->wh; -+ tw = m->ww; -+ ty = m->wy; -+ } -+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { -+ if (i < m->nmaster) { -+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i); -+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); -+ mx += WIDTH(c); -+ } else { -+ h = m->wh - mh; -+ resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), 0); -+ if (tw != m->ww) -+ tx += WIDTH(c); -+ } -+ } -+} -+ -+static void -+bstackhoriz(Monitor *m) { -+ int w, mh, mx, tx, ty, th; -+ unsigned int i, n; -+ Client *c; -+ -+ for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); -+ if (n == 0) -+ return; -+ if (n > m->nmaster) { -+ mh = m->nmaster ? m->mfact * m->wh : 0; -+ th = (m->wh - mh) / (n - m->nmaster); -+ ty = m->wy + mh; -+ } else { -+ th = mh = m->wh; -+ ty = m->wy; -+ } -+ for (i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { -+ if (i < m->nmaster) { -+ w = (m->ww - mx) / (MIN(n, m->nmaster) - i); -+ resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), 0); -+ mx += WIDTH(c); -+ } else { -+ resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), 0); -+ if (th != m->wh) -+ ty += HEIGHT(c); -+ } -+ } -+} diff --git a/dwm/.dwm/patches/dwm-focusmaster-20200717-bb2e722.diff b/dwm/.dwm/patches/dwm-focusmaster-20200717-bb2e722.diff deleted file mode 100644 index de49ddb..0000000 --- a/dwm/.dwm/patches/dwm-focusmaster-20200717-bb2e722.diff +++ /dev/null @@ -1,44 +0,0 @@ -From 3e020d93df3aaec92d2daa142cd1f0d5301b3197 Mon Sep 17 00:00:00 2001 -From: Mateus Auler -Date: Fri, 17 Jul 2020 12:36:36 -0300 -Subject: [PATCH] Ability to map a key combination to switch focus to - the master window. - ---- - dwm.c | 16 ++++++++++++++++ - 1 file changed, 16 insertions(+) - -diff --git a/dwm.c b/dwm.c -index 9fd0286..be01927 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -235,6 +235,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee); - static int xerrorstart(Display *dpy, XErrorEvent *ee); - static void zoom(const Arg *arg); - -+static void focusmaster(const Arg *arg); -+ - /* variables */ - static const char broken[] = "broken"; - static char stext[256]; -@@ -2150,3 +2152,17 @@ main(int argc, char *argv[]) - XCloseDisplay(dpy); - return EXIT_SUCCESS; - } -+ -+void -+focusmaster(const Arg *arg) -+{ -+ Client *c; -+ -+ if (selmon->nmaster < 1) -+ return; -+ -+ c = nexttiled(selmon->clients); -+ -+ if (c) -+ focus(c); -+} --- -2.27.0 - diff --git a/dwm/.dwm/patches/dwm-focusonnetactive-6.2.diff b/dwm/.dwm/patches/dwm-focusonnetactive-6.2.diff deleted file mode 100644 index 5d358d2..0000000 --- a/dwm/.dwm/patches/dwm-focusonnetactive-6.2.diff +++ /dev/null @@ -1,57 +0,0 @@ -From 286ca3bb1af08b452bf8140abcc23d4ef61baaa2 Mon Sep 17 00:00:00 2001 -From: bakkeby -Date: Tue, 7 Apr 2020 12:33:04 +0200 -Subject: [PATCH] Activate a window in response to _NET_ACTIVE_WINDOW - -By default, dwm response to client requests to _NET_ACTIVE_WINDOW client -messages by setting the urgency bit on the named window. - -This patch activates the window instead. - -Both behaviours are legitimate according to -https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472702304 - -One should decide which of these one should perform based on the message -senders' untestable claims that it represents the end-user. Setting the -urgency bit is the conservative decision. This patch implements the more -trusting alternative. - -It also allows dwm to work with `wmctrl -a` and other external window -management utilities - ---- - dwm.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/dwm.c b/dwm.c -index 4465af1..3919d47 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -514,6 +514,7 @@ clientmessage(XEvent *e) - { - XClientMessageEvent *cme = &e->xclient; - Client *c = wintoclient(cme->window); -+ unsigned int i; - - if (!c) - return; -@@ -523,8 +524,14 @@ clientmessage(XEvent *e) - setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ - || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); - } else if (cme->message_type == netatom[NetActiveWindow]) { -- if (c != selmon->sel && !c->isurgent) -- seturgent(c, 1); -+ for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); -+ if (i < LENGTH(tags)) { -+ const Arg a = {.ui = 1 << i}; -+ selmon = c->mon; -+ view(&a); -+ focus(c); -+ restack(selmon); -+ } - } - } - --- -2.17.1 - diff --git a/dwm/.dwm/patches/dwm-xrdb-6.2.diff b/dwm/.dwm/patches/dwm-xrdb-6.2.diff deleted file mode 100644 index 4c5a53f..0000000 --- a/dwm/.dwm/patches/dwm-xrdb-6.2.diff +++ /dev/null @@ -1,188 +0,0 @@ -diff --git a/config.def.h b/config.def.h -index 1c0b587..5db7d05 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -7,15 +7,16 @@ static const int showbar = 1; /* 0 means no bar */ - static const int topbar = 1; /* 0 means bottom bar */ - static const char *fonts[] = { "monospace:size=10" }; - static const char dmenufont[] = "monospace:size=10"; --static const char col_gray1[] = "#222222"; --static const char col_gray2[] = "#444444"; --static const char col_gray3[] = "#bbbbbb"; --static const char col_gray4[] = "#eeeeee"; --static const char col_cyan[] = "#005577"; --static const char *colors[][3] = { -- /* fg bg border */ -- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, -- [SchemeSel] = { col_gray4, col_cyan, col_cyan }, -+static char normbgcolor[] = "#222222"; -+static char normbordercolor[] = "#444444"; -+static char normfgcolor[] = "#bbbbbb"; -+static char selfgcolor[] = "#eeeeee"; -+static char selbordercolor[] = "#005577"; -+static char selbgcolor[] = "#005577"; -+static char *colors[][3] = { -+ /* fg bg border */ -+ [SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor }, -+ [SchemeSel] = { selfgcolor, selbgcolor, selbordercolor }, - }; - - /* tagging */ -@@ -56,7 +57,7 @@ static const Layout layouts[] = { - - /* commands */ - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ --static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -+static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbordercolor, "-sf", selfgcolor, NULL }; - static const char *termcmd[] = { "st", NULL }; - - static Key keys[] = { -@@ -84,6 +85,7 @@ static Key keys[] = { - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, -+ { MODKEY, XK_F5, xrdb, {.v = NULL } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) -diff --git a/drw.c b/drw.c -index 8fd1ca4..e4968a0 100644 ---- a/drw.c -+++ b/drw.c -@@ -207,7 +207,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname) - /* Wrapper to create color schemes. The caller has to call free(3) on the - * returned color scheme when done using it. */ - Clr * --drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount) -+drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount) - { - size_t i; - Clr *ret; -diff --git a/drw.h b/drw.h -index 4bcd5ad..42b04ce 100644 ---- a/drw.h -+++ b/drw.h -@@ -39,7 +39,7 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in - - /* Colorscheme abstraction */ - void drw_clr_create(Drw *drw, Clr *dest, const char *clrname); --Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount); -+Clr *drw_scm_create(Drw *drw, char *clrnames[], size_t clrcount); - - /* Cursor abstraction */ - Cur *drw_cur_create(Drw *drw, int shape); -diff --git a/dwm.c b/dwm.c -index 4465af1..7fa45c5 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - #include - #ifdef XINERAMA - #include -@@ -56,6 +57,21 @@ - #define HEIGHT(X) ((X)->h + 2 * (X)->bw) - #define TAGMASK ((1 << LENGTH(tags)) - 1) - #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) -+#define XRDB_LOAD_COLOR(R,V) if (XrmGetResource(xrdb, R, NULL, &type, &value) == True) { \ -+ if (value.addr != NULL && strnlen(value.addr, 8) == 7 && value.addr[0] == '#') { \ -+ int i = 1; \ -+ for (; i <= 6; i++) { \ -+ if (value.addr[i] < 48) break; \ -+ if (value.addr[i] > 57 && value.addr[i] < 65) break; \ -+ if (value.addr[i] > 70 && value.addr[i] < 97) break; \ -+ if (value.addr[i] > 102) break; \ -+ } \ -+ if (i == 7) { \ -+ strncpy(V, value.addr, 7); \ -+ V[7] = '\0'; \ -+ } \ -+ } \ -+ } - - /* enums */ - enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ -@@ -177,6 +193,7 @@ static void grabkeys(void); - static void incnmaster(const Arg *arg); - static void keypress(XEvent *e); - static void killclient(const Arg *arg); -+static void loadxrdb(void); - static void manage(Window w, XWindowAttributes *wa); - static void mappingnotify(XEvent *e); - static void maprequest(XEvent *e); -@@ -232,6 +249,7 @@ static Monitor *wintomon(Window w); - static int xerror(Display *dpy, XErrorEvent *ee); - static int xerrordummy(Display *dpy, XErrorEvent *ee); - static int xerrorstart(Display *dpy, XErrorEvent *ee); -+static void xrdb(const Arg *arg); - static void zoom(const Arg *arg); - - /* variables */ -@@ -1014,6 +1032,37 @@ killclient(const Arg *arg) - } - } - -+void -+loadxrdb() -+{ -+ Display *display; -+ char * resm; -+ XrmDatabase xrdb; -+ char *type; -+ XrmValue value; -+ -+ display = XOpenDisplay(NULL); -+ -+ if (display != NULL) { -+ resm = XResourceManagerString(display); -+ -+ if (resm != NULL) { -+ xrdb = XrmGetStringDatabase(resm); -+ -+ if (xrdb != NULL) { -+ XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor); -+ XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor); -+ XRDB_LOAD_COLOR("dwm.normfgcolor", normfgcolor); -+ XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor); -+ XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor); -+ XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor); -+ } -+ } -+ } -+ -+ XCloseDisplay(display); -+} -+ - void - manage(Window w, XWindowAttributes *wa) - { -@@ -2110,6 +2159,17 @@ xerrorstart(Display *dpy, XErrorEvent *ee) - return -1; - } - -+void -+xrdb(const Arg *arg) -+{ -+ loadxrdb(); -+ int i; -+ for (i = 0; i < LENGTH(colors); i++) -+ scheme[i] = drw_scm_create(drw, colors[i], 3); -+ focus(NULL); -+ arrange(NULL); -+} -+ - void - zoom(const Arg *arg) - { -@@ -2136,6 +2196,8 @@ main(int argc, char *argv[]) - if (!(dpy = XOpenDisplay(NULL))) - die("dwm: cannot open display"); - checkotherwm(); -+ XrmInitialize(); -+ loadxrdb(); - setup(); - #ifdef __OpenBSD__ - if (pledge("stdio rpath proc exec", NULL) == -1)