diff --git a/dmenu.c b/dmenu.c index 643f9e2..920fa52 100644 --- a/dmenu.c +++ b/dmenu.c @@ -15,6 +15,7 @@ #include #endif #include +#include #include "drw.h" #include "util.h" @@ -736,6 +737,31 @@ usage(void) exit(1); } +void +read_Xresources(void) { + XrmInitialize(); + + char* xrm; + if ((xrm = XResourceManagerString(drw->dpy))) { + char *type; + XrmDatabase xdb = XrmGetStringDatabase(xrm); + XrmValue xval; + + if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval) == True) /* font or font set */ + fonts[0] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.color0", "*", &type, &xval) == True) /* normal background color */ + colors[SchemeSel][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.color7", "*", &type, &xval) == True) /* normal foreground color */ + colors[SchemeNorm][ColFg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.color6", "*", &type, &xval) == True) /* selected background color */ + colors[SchemeSel][ColBg] = strdup(xval.addr); + if (XrmGetResource(xdb, "dmenu.color0", "*", &type, &xval) == True) /* selected foreground color */ + colors[SchemeSel][ColFg] = strdup(xval.addr); + + XrmDestroyDatabase(xdb); + } +} + int main(int argc, char *argv[]) { @@ -793,6 +819,7 @@ main(int argc, char *argv[]) parentwin); xinitvisual(); drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap); + read_Xresources(); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h;