Add colors and fonts to config.h (#115)
Adds a set of config vars to control window fg/bg, bar fg/bg, mark color and bar font. This allows everything that can be done from .Xresources to be configurable from config.h. Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com>
This commit is contained in:
parent
850bc788c3
commit
8934744c60
10
config.def.h
10
config.def.h
@ -4,9 +4,17 @@
|
|||||||
static const int WIN_WIDTH = 800;
|
static const int WIN_WIDTH = 800;
|
||||||
static const int WIN_HEIGHT = 600;
|
static const int WIN_HEIGHT = 600;
|
||||||
|
|
||||||
/* colors and font are configured via X resource properties.
|
/* colors and font can be overwritten via X resource properties.
|
||||||
* See nsxiv(1), X(7) section Resources and xrdb(1) for more information.
|
* See nsxiv(1), X(7) section Resources and xrdb(1) for more information.
|
||||||
*/
|
*/
|
||||||
|
static const char *DEFAULT_WIN_BG = "white";
|
||||||
|
static const char *DEFAULT_WIN_FG = "black";
|
||||||
|
static const char *DEFAULT_MARK_COLOR = NULL; /* NULL means it will default to window foreground */
|
||||||
|
#if HAVE_LIBFONTS
|
||||||
|
static const char *DEFAULT_BAR_BG = NULL; /* NULL means it will default to window background */
|
||||||
|
static const char *DEFAULT_BAR_FG = NULL; /* NULL means it will default to window foreground */
|
||||||
|
static const char *DEFAULT_FONT = "monospace-8";
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _TITLE_CONFIG
|
#ifdef _TITLE_CONFIG
|
||||||
|
12
window.c
12
window.c
@ -133,20 +133,20 @@ void win_init(win_t *win)
|
|||||||
res_man = XResourceManagerString(e->dpy);
|
res_man = XResourceManagerString(e->dpy);
|
||||||
db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man);
|
db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man);
|
||||||
|
|
||||||
win_bg = win_res(db, RES_CLASS ".window.background", "white");
|
win_bg = win_res(db, RES_CLASS ".window.background", DEFAULT_WIN_BG);
|
||||||
win_fg = win_res(db, RES_CLASS ".window.foreground", "black");
|
win_fg = win_res(db, RES_CLASS ".window.foreground", DEFAULT_WIN_FG);
|
||||||
mrk_fg = win_res(db, RES_CLASS ".mark.foreground", win_fg);
|
mrk_fg = win_res(db, RES_CLASS ".mark.foreground", DEFAULT_MARK_COLOR ? DEFAULT_MARK_COLOR : win_fg);
|
||||||
win_alloc_color(e, win_bg, &win->win_bg);
|
win_alloc_color(e, win_bg, &win->win_bg);
|
||||||
win_alloc_color(e, win_fg, &win->win_fg);
|
win_alloc_color(e, win_fg, &win->win_fg);
|
||||||
win_alloc_color(e, mrk_fg, &win->mrk_fg);
|
win_alloc_color(e, mrk_fg, &win->mrk_fg);
|
||||||
|
|
||||||
#if HAVE_LIBFONTS
|
#if HAVE_LIBFONTS
|
||||||
bar_bg = win_res(db, RES_CLASS ".bar.background", win_bg);
|
bar_bg = win_res(db, RES_CLASS ".bar.background", DEFAULT_BAR_BG ? DEFAULT_BAR_BG : win_bg);
|
||||||
bar_fg = win_res(db, RES_CLASS ".bar.foreground", win_fg);
|
bar_fg = win_res(db, RES_CLASS ".bar.foreground", DEFAULT_BAR_FG ? DEFAULT_BAR_FG : win_fg);
|
||||||
xft_alloc_color(e, bar_bg, &win->bar_bg);
|
xft_alloc_color(e, bar_bg, &win->bar_bg);
|
||||||
xft_alloc_color(e, bar_fg, &win->bar_fg);
|
xft_alloc_color(e, bar_fg, &win->bar_fg);
|
||||||
|
|
||||||
f = win_res(db, RES_CLASS ".bar.font", "monospace-8");
|
f = win_res(db, RES_CLASS ".bar.font", DEFAULT_FONT);
|
||||||
win_init_font(e, f);
|
win_init_font(e, f);
|
||||||
|
|
||||||
win->bar.l.size = BAR_L_LEN;
|
win->bar.l.size = BAR_L_LEN;
|
||||||
|
Loading…
Reference in New Issue
Block a user