~kris/suckless

dmenu

b119b55c05ad2c57ff084afb0a0aaf3ad9425487 — Luke Smith 6 years ago 4327a57
xresources
1 files changed, 27 insertions(+), 0 deletions(-)

M dmenu.c
M dmenu.c => dmenu.c +27 -0
@@ 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;