xresources

This commit is contained in:
Luke Smith 2020-02-25 19:33:40 -05:00
parent 4327a57df2
commit b119b55c05
No known key found for this signature in database
GPG Key ID: 4C50B54A911F6252

27
dmenu.c
View File

@ -15,6 +15,7 @@
#include <X11/extensions/Xinerama.h>
#endif
#include <X11/Xft/Xft.h>
#include <X11/Xresource.h>
#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;