Simplify X resource retrieval
Also makes the color names in config.def.h constant again.
This commit is contained in:
parent
f7fc6637f3
commit
9d244da512
10
config.def.h
10
config.def.h
|
@ -14,11 +14,11 @@ static const char * const BAR_FONT = "monospace:size=8";
|
||||||
/* colors:
|
/* colors:
|
||||||
* (see X(7) section "COLOR NAMES" for valid values)
|
* (see X(7) section "COLOR NAMES" for valid values)
|
||||||
*/
|
*/
|
||||||
static char const * WIN_BG_COLOR = "#555555";
|
static const char * const WIN_BG_COLOR = "#555555";
|
||||||
static char const * WIN_FS_COLOR = "#000000";
|
static const char * const WIN_FS_COLOR = "#000000";
|
||||||
static char const * SEL_COLOR = "#EEEEEE";
|
static const char * const SEL_COLOR = "#EEEEEE";
|
||||||
static char const * BAR_BG_COLOR = "#222222";
|
static const char * const BAR_BG_COLOR = "#222222";
|
||||||
static char const * BAR_FG_COLOR = "#EEEEEE";
|
static const char * const BAR_FG_COLOR = "#EEEEEE";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _IMAGE_CONFIG
|
#ifdef _IMAGE_CONFIG
|
||||||
|
|
35
window.c
35
window.c
|
@ -102,7 +102,7 @@ void win_check_wm_support(Display *dpy, Window root)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_res(Display *dpy, const char *name, const char **dst)
|
const char* win_res(Display *dpy, const char *name, const char *def)
|
||||||
{
|
{
|
||||||
char *type;
|
char *type;
|
||||||
XrmValue ret;
|
XrmValue ret;
|
||||||
|
@ -111,14 +111,14 @@ void win_res(Display *dpy, const char *name, const char **dst)
|
||||||
|
|
||||||
XrmInitialize();
|
XrmInitialize();
|
||||||
|
|
||||||
if ((res_man = XResourceManagerString(dpy)) == NULL)
|
if ((res_man = XResourceManagerString(dpy)) != NULL &&
|
||||||
return;
|
(db = XrmGetStringDatabase(res_man)) != NULL &&
|
||||||
|
XrmGetResource(db, name, name, &type, &ret) && STREQ(type, "String"))
|
||||||
if ((db = XrmGetStringDatabase(res_man)) == NULL)
|
{
|
||||||
return;
|
return ret.addr;
|
||||||
|
} else {
|
||||||
if (XrmGetResource(db, name, name, &type, &ret) && STREQ(type, "String"))
|
return def;
|
||||||
*dst = ret.addr;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INIT_ATOM_(atom) \
|
#define INIT_ATOM_(atom) \
|
||||||
|
@ -144,18 +144,17 @@ void win_init(win_t *win)
|
||||||
if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0)
|
if (setlocale(LC_CTYPE, "") == NULL || XSupportsLocale() == 0)
|
||||||
error(0, 0, "No locale support");
|
error(0, 0, "No locale support");
|
||||||
|
|
||||||
win_res(e->dpy, RES_CLASS ".background", &WIN_BG_COLOR);
|
|
||||||
win_res(e->dpy, RES_CLASS ".background", &BAR_FG_COLOR);
|
|
||||||
win_res(e->dpy, RES_CLASS ".foreground", &BAR_BG_COLOR);
|
|
||||||
win_res(e->dpy, RES_CLASS ".foreground", &SEL_COLOR);
|
|
||||||
|
|
||||||
win_init_font(e, BAR_FONT);
|
win_init_font(e, BAR_FONT);
|
||||||
|
|
||||||
win_alloc_color(e, WIN_BG_COLOR, &win->bgcol);
|
win_alloc_color(e, win_res(e->dpy, RES_CLASS ".background", WIN_BG_COLOR),
|
||||||
|
&win->bgcol);
|
||||||
win_alloc_color(e, WIN_FS_COLOR, &win->fscol);
|
win_alloc_color(e, WIN_FS_COLOR, &win->fscol);
|
||||||
win_alloc_color(e, SEL_COLOR, &win->selcol);
|
win_alloc_color(e, win_res(e->dpy, RES_CLASS ".foreground", SEL_COLOR),
|
||||||
win_alloc_color(e, BAR_BG_COLOR, &win->bar.bgcol);
|
&win->selcol);
|
||||||
win_alloc_color(e, BAR_FG_COLOR, &win->bar.fgcol);
|
win_alloc_color(e, win_res(e->dpy, RES_CLASS ".foreground", BAR_BG_COLOR),
|
||||||
|
&win->bar.bgcol);
|
||||||
|
win_alloc_color(e, win_res(e->dpy, RES_CLASS ".background", BAR_FG_COLOR),
|
||||||
|
&win->bar.fgcol);
|
||||||
|
|
||||||
win->bar.l.size = BAR_L_LEN;
|
win->bar.l.size = BAR_L_LEN;
|
||||||
win->bar.r.size = BAR_R_LEN;
|
win->bar.r.size = BAR_R_LEN;
|
||||||
|
|
Loading…
Reference in a new issue