mirror of
https://github.com/bakkeby/dwm-flexipatch
synced 2024-11-10 19:10:48 +00:00
Adding xrdb patch
This commit is contained in:
parent
30e0a3b5e4
commit
f8f67508d8
65
config.def.h
65
config.def.h
@ -24,11 +24,39 @@ static const int showsystray = 1; /* 0 means no systray */
|
|||||||
#endif // SYSTRAY_PATCH
|
#endif // SYSTRAY_PATCH
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
static const char col_gray1[] = "#222222";
|
|
||||||
static const char col_gray2[] = "#444444";
|
static char normfgcolor[] = "#bbbbbb";
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
static char normbgcolor[] = "#222222";
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static char normbordercolor[] = "#444444";
|
||||||
static const char col_cyan[] = "#005577";
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
static char normflcolor[] = "#db8fd9";
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
|
||||||
|
static char selfgcolor[] = "#eeeeee";
|
||||||
|
static char selbgcolor[] = "#005577";
|
||||||
|
static char selbordercolor[] = "#005577";
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
static char selflcolor[] = "#005577";
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
static char hidfgcolor[] = "#005577";
|
||||||
|
static char hidbgcolor[] = "#222222";
|
||||||
|
static char hidbordercolor[] = "#005577";
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
static char hidflcolor[] = "#f76e0c";
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
|
|
||||||
|
#if TITLECOLOR_PATCH
|
||||||
|
static char titlefgcolor[] = "#eeeeee";
|
||||||
|
static char titlebgcolor[] = "#005577";
|
||||||
|
static char titlebordercolor[] = "#005577";
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
static char titleflcolor[] = "#005577";
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
#endif // TITLECOLOR_PATCH
|
||||||
|
|
||||||
#if ALPHA_PATCH
|
#if ALPHA_PATCH
|
||||||
static const unsigned int baralpha = 0xd0;
|
static const unsigned int baralpha = 0xd0;
|
||||||
static const unsigned int borderalpha = OPAQUE;
|
static const unsigned int borderalpha = OPAQUE;
|
||||||
@ -36,7 +64,7 @@ static const unsigned int alphas[][3] = {
|
|||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
||||||
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
|
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
|
||||||
#if AWESOMEBA R_PATCH
|
#if AWESOMEBAR_PATCH
|
||||||
[SchemeHid] = { OPAQUE, baralpha, borderalpha },
|
[SchemeHid] = { OPAQUE, baralpha, borderalpha },
|
||||||
#endif // AWESOMEBAR_PATCH
|
#endif // AWESOMEBAR_PATCH
|
||||||
#if TITLECOLOR_PATCH
|
#if TITLECOLOR_PATCH
|
||||||
@ -45,27 +73,27 @@ static const unsigned int alphas[][3] = {
|
|||||||
};
|
};
|
||||||
#endif // ALPHA_PATCH
|
#endif // ALPHA_PATCH
|
||||||
#if FLOAT_BORDER_COLOR_PATCH
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
static const char *colors[][4] = {
|
static char *colors[][4] = {
|
||||||
/* fg bg border float */
|
/* fg bg border float */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2, col_gray2 },
|
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor, normflcolor },
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan, col_cyan },
|
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor, selflcolor },
|
||||||
#if AWESOMEBAR_PATCH
|
#if AWESOMEBAR_PATCH
|
||||||
[SchemeHid] = { col_cyan, col_gray1, col_cyan, col_cyan },
|
[SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor, hidflcolor },
|
||||||
#endif // AWESOMEBAR_PATCH
|
#endif // AWESOMEBAR_PATCH
|
||||||
#if TITLECOLOR_PATCH
|
#if TITLECOLOR_PATCH
|
||||||
[SchemeTitle] = { col_gray4, col_cyan, col_cyan, col_cyan },
|
[SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor, titleflcolor },
|
||||||
#endif // TITLECOLOR_PATCH
|
#endif // TITLECOLOR_PATCH
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
static const char *colors[][3] = {
|
static char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { normfgcolor, normbgcolor, normbordercolor },
|
||||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
[SchemeSel] = { selfgcolor, selbgcolor, selbordercolor },
|
||||||
#if AWESOMEBAR_PATCH
|
#if AWESOMEBAR_PATCH
|
||||||
[SchemeHid] = { col_cyan, col_gray1, col_cyan },
|
[SchemeHid] = { hidfgcolor, hidbgcolor, hidbordercolor },
|
||||||
#endif // AWESOMEBAR_PATCH
|
#endif // AWESOMEBAR_PATCH
|
||||||
#if TITLECOLOR_PATCH
|
#if TITLECOLOR_PATCH
|
||||||
[SchemeTitle] = { col_gray4, col_cyan, col_cyan },
|
[SchemeTitle] = { titlefgcolor, titlebgcolor, titlebordercolor },
|
||||||
#endif // TITLECOLOR_PATCH
|
#endif // TITLECOLOR_PATCH
|
||||||
};
|
};
|
||||||
#endif // FLOAT_BORDER_COLOR_PATCH
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
@ -221,7 +249,7 @@ static const Layout layouts[] = {
|
|||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
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", selbgcolor, "-sf", selfgcolor, NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
@ -276,6 +304,9 @@ static Key keys[] = {
|
|||||||
{ MODKEY|ShiftMask, XK_r, self_restart, {0} },
|
{ MODKEY|ShiftMask, XK_r, self_restart, {0} },
|
||||||
#endif // SELFRESTART_PATCH
|
#endif // SELFRESTART_PATCH
|
||||||
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
{ MODKEY|ShiftMask, XK_q, quit, {0} },
|
||||||
|
#if XRDB_PATCH
|
||||||
|
{ MODKEY|ShiftMask, XK_F5, xrdb, {.v = NULL } },
|
||||||
|
#endif // XRDB_PATCH
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
|
18
drw.c
18
drw.c
@ -237,12 +237,18 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
* returned color scheme when done using it. */
|
* returned color scheme when done using it. */
|
||||||
Clr *
|
Clr *
|
||||||
#if ALPHA_PATCH
|
drw_scm_create(
|
||||||
drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
|
Drw *drw,
|
||||||
#else
|
#if XRDB_PATCH
|
||||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
char *clrnames[],
|
||||||
#endif // ALPHA_PATCH
|
#else
|
||||||
{
|
const char *clrnames[],
|
||||||
|
#endif // XRDB_PATCH
|
||||||
|
#if ALPHA_PATCH
|
||||||
|
const unsigned int alphas[],
|
||||||
|
#endif // ALPHA_PATCH
|
||||||
|
size_t clrcount
|
||||||
|
) {
|
||||||
size_t i;
|
size_t i;
|
||||||
Clr *ret;
|
Clr *ret;
|
||||||
|
|
||||||
|
27
drw.h
27
drw.h
@ -51,13 +51,26 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
|||||||
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
/* Colorscheme abstraction */
|
/* Colorscheme abstraction */
|
||||||
#if ALPHA_PATCH
|
void drw_clr_create(
|
||||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
|
Drw *drw,
|
||||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
|
Clr *dest,
|
||||||
#else
|
const char *clrname
|
||||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
#if ALPHA_PATCH
|
||||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
, unsigned int alpha
|
||||||
#endif // ALPHA_PATCH
|
#endif // ALPHA_PATCH
|
||||||
|
);
|
||||||
|
Clr *drw_scm_create(
|
||||||
|
Drw *drw,
|
||||||
|
#if XRDB_PATCH
|
||||||
|
char *clrnames[],
|
||||||
|
#else
|
||||||
|
const char *clrnames[],
|
||||||
|
#endif // XRDB_PATCH
|
||||||
|
#if ALPHA_PATCH
|
||||||
|
const unsigned int alphas[],
|
||||||
|
#endif // ALPHA_PATCH
|
||||||
|
size_t clrcount
|
||||||
|
);
|
||||||
|
|
||||||
/* Cursor abstraction */
|
/* Cursor abstraction */
|
||||||
Cur *drw_cur_create(Drw *drw, int shape);
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
5
dwm.c
5
dwm.c
@ -3106,6 +3106,11 @@ main(int argc, char *argv[])
|
|||||||
if (!(dpy = XOpenDisplay(NULL)))
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
die("dwm: cannot open display");
|
die("dwm: cannot open display");
|
||||||
checkotherwm();
|
checkotherwm();
|
||||||
|
#if XRDB_PATCH
|
||||||
|
XrmInitialize();
|
||||||
|
loadxrdb();
|
||||||
|
#endif
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||||
|
@ -90,6 +90,10 @@
|
|||||||
#include "zoomswap.c"
|
#include "zoomswap.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XRDB_PATCH
|
||||||
|
#include "xrdb.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Layouts */
|
/* Layouts */
|
||||||
|
|
||||||
#if BSTACK_LAYOUT
|
#if BSTACK_LAYOUT
|
||||||
|
@ -78,10 +78,18 @@
|
|||||||
#include "vanitygaps.h"
|
#include "vanitygaps.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if WARP_PATCH
|
||||||
|
#include "warp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ZOOMSWAP_PATCH
|
#if ZOOMSWAP_PATCH
|
||||||
#include "zoomswap.h"
|
#include "zoomswap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XRDB_PATCH
|
||||||
|
#include "xrdb.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Layouts */
|
/* Layouts */
|
||||||
|
|
||||||
#if BSTACK_LAYOUT
|
#if BSTACK_LAYOUT
|
||||||
|
75
patch/xrdb.c
Normal file
75
patch/xrdb.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
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.normfgcolor", normfgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.normbgcolor", normbgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.normbordercolor", normbordercolor);
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
XRDB_LOAD_COLOR("dwm.normflcolor", normflcolor);
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
|
||||||
|
XRDB_LOAD_COLOR("dwm.selfgcolor", selfgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.selbgcolor", selbgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.selbordercolor", selbordercolor);
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
XRDB_LOAD_COLOR("dwm.selflcolor", selflcolor);
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
|
||||||
|
#if AWESOMEBAR_PATCH
|
||||||
|
XRDB_LOAD_COLOR("dwm.hidfgcolor", hidfgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.hidbgcolor", hidbgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.hidbordercolor", hidbordercolor);
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
XRDB_LOAD_COLOR("dwm.hidflcolor", hidflcolor);
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
#endif // AWESOMEBAR_PATCH
|
||||||
|
|
||||||
|
#if TITLECOLOR_PATCH
|
||||||
|
XRDB_LOAD_COLOR("dwm.titlefgcolor", titlefgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.titlebgcolor", titlebgcolor);
|
||||||
|
XRDB_LOAD_COLOR("dwm.titlebordercolor", titlebordercolor);
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
XRDB_LOAD_COLOR("dwm.titleflcolor", titleflcolor);
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
#endif // TITLECOLOR_PATCH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XCloseDisplay(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xrdb(const Arg *arg)
|
||||||
|
{
|
||||||
|
loadxrdb();
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
|
scheme[i] = drw_scm_create(drw, colors[i],
|
||||||
|
#if ALPHA_PATCH
|
||||||
|
alphas[i],
|
||||||
|
#endif // ALPHA_PATCH
|
||||||
|
#if FLOAT_BORDER_COLOR_PATCH
|
||||||
|
4
|
||||||
|
#else
|
||||||
|
3
|
||||||
|
#endif // FLOAT_BORDER_COLOR_PATCH
|
||||||
|
);
|
||||||
|
focus(NULL);
|
||||||
|
arrange(NULL);
|
||||||
|
}
|
21
patch/xrdb.h
Normal file
21
patch/xrdb.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <X11/Xresource.h>
|
||||||
|
|
||||||
|
#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'; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadxrdb(void);
|
||||||
|
static void xrdb(const Arg *arg);
|
||||||
|
|
@ -285,6 +285,11 @@
|
|||||||
*/
|
*/
|
||||||
#define WINDOWROLERULE_PATCH 0
|
#define WINDOWROLERULE_PATCH 0
|
||||||
|
|
||||||
|
/* Allows dwm to read colors from xrdb (.Xresources) at run time.
|
||||||
|
* https://dwm.suckless.org/patches/xrdb/
|
||||||
|
*/
|
||||||
|
#define XRDB_PATCH 0
|
||||||
|
|
||||||
/* The zoomswap patch allows a master and a stack window to swap places
|
/* The zoomswap patch allows a master and a stack window to swap places
|
||||||
* rather than every window on the screen changing position.
|
* rather than every window on the screen changing position.
|
||||||
* https://dwm.suckless.org/patches/zoomswap/
|
* https://dwm.suckless.org/patches/zoomswap/
|
||||||
|
Loading…
Reference in New Issue
Block a user