make xresources class name configurable in config.h

This commit is contained in:
explosion-mental 2023-03-15 23:32:20 -05:00 committed by NRK
parent 28018e92d3
commit 3097037624
2 changed files with 13 additions and 13 deletions

View file

@ -6,14 +6,14 @@ static const int WIN_HEIGHT = 600;
/* colors and font can be overwritten via X resource properties.
* 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 */
* X resource default value */
static const char *WIN_BG[] = { "Nsxiv.window.background", "white" };
static const char *WIN_FG[] = { "Nsxiv.window.foreground", "black" };
static const char *MARK_FG[] = { "Nsxiv.mark.foreground", 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";
static const char *BAR_BG[] = { "Nsxiv.bar.background", NULL }; /* NULL means it will default to window background */
static const char *BAR_FG[] = { "Nsxiv.bar.foreground", NULL }; /* NULL means it will default to window foreground */
static const char *BAR_FONT[] = { "Nsxiv.bar.font", "monospace-8" };
/* if true, statusbar appears on top of the window */
static const bool TOP_STATUSBAR = false;

View file

@ -141,20 +141,20 @@ void win_init(win_t *win)
res_man = XResourceManagerString(e->dpy);
db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man);
win_bg = win_res(db, RES_CLASS ".window.background", DEFAULT_WIN_BG);
win_fg = win_res(db, RES_CLASS ".window.foreground", DEFAULT_WIN_FG);
mrk_fg = win_res(db, RES_CLASS ".mark.foreground", DEFAULT_MARK_COLOR ? DEFAULT_MARK_COLOR : win_fg);
win_bg = win_res(db, WIN_BG[0], WIN_BG[1]);
win_fg = win_res(db, WIN_FG[0], WIN_FG[1]);
mrk_fg = win_res(db, MARK_FG[0], MARK_FG[1] ? MARK_FG[1] : win_fg);
win_alloc_color(e, win_bg, &win->win_bg);
win_alloc_color(e, win_fg, &win->win_fg);
win_alloc_color(e, mrk_fg, &win->mrk_fg);
#if HAVE_LIBFONTS
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", DEFAULT_BAR_FG ? DEFAULT_BAR_FG : win_fg);
bar_bg = win_res(db, BAR_BG[0], BAR_BG[1] ? BAR_BG[1] : win_bg);
bar_fg = win_res(db, BAR_FG[0], BAR_FG[1] ? BAR_FG[1] : win_fg);
xft_alloc_color(e, bar_bg, &win->bar_bg);
xft_alloc_color(e, bar_fg, &win->bar_fg);
f = win_res(db, RES_CLASS ".bar.font", DEFAULT_FONT);
f = win_res(db, BAR_FONT[0], BAR_FONT[1]);
win_init_font(e, f);
win->bar.l.buf = lbuf;