nsxiv8934744
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.
+15 −7
2 files changed
- M config.def.h +9 −1
- M window.c +6 −6
| @@ -4,9 +4,17 @@ | |||
| 4 | 4 | static const int WIN_WIDTH = 800; | |
| 5 | 5 | static const int WIN_HEIGHT = 600; | |
| 6 | 6 | ||
| 7 | − | /* colors and font are configured via X resource properties. | |
| 7 | + | /* colors and font can be overwritten via X resource properties. | |
| 8 | 8 | * See nsxiv(1), X(7) section Resources and xrdb(1) for more information. | |
| 9 | 9 | */ | |
| 10 | + | static const char *DEFAULT_WIN_BG = "white"; | |
| 11 | + | static const char *DEFAULT_WIN_FG = "black"; | |
| 12 | + | static const char *DEFAULT_MARK_COLOR = NULL; /* NULL means it will default to window foreground */ | |
| 13 | + | #if HAVE_LIBFONTS | |
| 14 | + | static const char *DEFAULT_BAR_BG = NULL; /* NULL means it will default to window background */ | |
| 15 | + | static const char *DEFAULT_BAR_FG = NULL; /* NULL means it will default to window foreground */ | |
| 16 | + | static const char *DEFAULT_FONT = "monospace-8"; | |
| 17 | + | #endif | |
| 10 | 18 | ||
| 11 | 19 | #endif | |
| 12 | 20 | #ifdef _TITLE_CONFIG | |
| @@ -133,20 +133,20 @@ void win_init(win_t *win) | |||
| 133 | 133 | res_man = XResourceManagerString(e->dpy); | |
| 134 | 134 | db = res_man == NULL ? NULL : XrmGetStringDatabase(res_man); | |
| 135 | 135 | ||
| 136 | − | win_bg = win_res(db, RES_CLASS ".window.background", "white"); | |
| 137 | − | win_fg = win_res(db, RES_CLASS ".window.foreground", "black"); | |
| 138 | − | mrk_fg = win_res(db, RES_CLASS ".mark.foreground", win_fg); | |
| 136 | + | win_bg = win_res(db, RES_CLASS ".window.background", DEFAULT_WIN_BG); | |
| 137 | + | win_fg = win_res(db, RES_CLASS ".window.foreground", DEFAULT_WIN_FG); | |
| 138 | + | mrk_fg = win_res(db, RES_CLASS ".mark.foreground", DEFAULT_MARK_COLOR ? DEFAULT_MARK_COLOR : win_fg); | |
| 139 | 139 | win_alloc_color(e, win_bg, &win->win_bg); | |
| 140 | 140 | win_alloc_color(e, win_fg, &win->win_fg); | |
| 141 | 141 | win_alloc_color(e, mrk_fg, &win->mrk_fg); | |
| 142 | 142 | ||
| 143 | 143 | #if HAVE_LIBFONTS | |
| 144 | − | bar_bg = win_res(db, RES_CLASS ".bar.background", win_bg); | |
| 145 | − | bar_fg = win_res(db, RES_CLASS ".bar.foreground", win_fg); | |
| 144 | + | bar_bg = win_res(db, RES_CLASS ".bar.background", DEFAULT_BAR_BG ? DEFAULT_BAR_BG : win_bg); | |
| 145 | + | bar_fg = win_res(db, RES_CLASS ".bar.foreground", DEFAULT_BAR_FG ? DEFAULT_BAR_FG : win_fg); | |
| 146 | 146 | xft_alloc_color(e, bar_bg, &win->bar_bg); | |
| 147 | 147 | xft_alloc_color(e, bar_fg, &win->bar_fg); | |
| 148 | 148 | ||
| 149 | − | f = win_res(db, RES_CLASS ".bar.font", "monospace-8"); | |
| 149 | + | f = win_res(db, RES_CLASS ".bar.font", DEFAULT_FONT); | |
| 150 | 150 | win_init_font(e, f); | |
| 151 | 151 | ||
| 152 | 152 | win->bar.l.size = BAR_L_LEN; | |