dmenu

Kris's build of dmenu
git clone git clone https://git.krisyotam.com/krisyotam/dmenu.git
Log | Files | Refs | README | LICENSE

xresources.c (4622B)


      1 #include <X11/Xresource.h>
      2 
      3 void
      4 readxresources(void)
      5 {
      6 	XrmInitialize();
      7 
      8 	char* xrm;
      9 	if ((xrm = XResourceManagerString(drw->dpy))) {
     10 		char *type;
     11 		XrmDatabase xdb = XrmGetStringDatabase(xrm);
     12 		XrmValue xval;
     13 
     14 		if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval))
     15 			#if PANGO_PATCH
     16 			strcpy(font, xval.addr);
     17 			#else
     18 			fonts[0] = strdup(xval.addr);
     19 			#endif // PANGO_PATCH
     20 		#if !PANGO_PATCH
     21 		else
     22 			fonts[0] = strdup(fonts[0]);
     23 		#endif // PANGO_PATCH
     24 		if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval))
     25 			colors[SchemeNorm][ColBg] = strdup(xval.addr);
     26 		if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval))
     27 			colors[SchemeNorm][ColFg] = strdup(xval.addr);
     28 		if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval))
     29 			colors[SchemeSel][ColBg] = strdup(xval.addr);
     30 		if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval))
     31 			colors[SchemeSel][ColFg] = strdup(xval.addr);
     32 		if (XrmGetResource(xdb, "dmenu.outbackground", "*", &type, &xval))
     33 			colors[SchemeOut][ColBg] = strdup(xval.addr);
     34 		if (XrmGetResource(xdb, "dmenu.outforeground", "*", &type, &xval))
     35 			colors[SchemeOut][ColFg] = strdup(xval.addr);
     36 		#if MORECOLOR_PATCH
     37 		if (XrmGetResource(xdb, "dmenu.midbackground", "*", &type, &xval))
     38 			colors[SchemeMid][ColBg] = strdup(xval.addr);
     39 		if (XrmGetResource(xdb, "dmenu.midforeground", "*", &type, &xval))
     40 			colors[SchemeMid][ColFg] = strdup(xval.addr);
     41 		#endif // MORECOLOR_PATCH
     42 		#if BORDER_PATCH
     43 		if (XrmGetResource(xdb, "dmenu.bordercolor", "*", &type, &xval))
     44 			colors[SchemeBorder][ColBg] = strdup(xval.addr);
     45 		#endif // BORDER_PATCH
     46 		#if HIGHLIGHT_PATCH
     47 		if (XrmGetResource(xdb, "dmenu.selhlbackground", "*", &type, &xval))
     48 			colors[SchemeSelHighlight][ColBg] = strdup(xval.addr);
     49 		if (XrmGetResource(xdb, "dmenu.selhlforeground", "*", &type, &xval))
     50 			colors[SchemeSelHighlight][ColFg] = strdup(xval.addr);
     51 		if (XrmGetResource(xdb, "dmenu.hlbackground", "*", &type, &xval))
     52 			colors[SchemeNormHighlight][ColBg] = strdup(xval.addr);
     53 		if (XrmGetResource(xdb, "dmenu.hlforeground", "*", &type, &xval))
     54 			colors[SchemeNormHighlight][ColFg] = strdup(xval.addr);
     55 		#endif // HIGHLIGHT_PATCH
     56 		#if HIGHPRIORITY_PATCH
     57 		if (XrmGetResource(xdb, "dmenu.hpbackground", "*", &type, &xval))
     58 			colors[SchemeHp][ColBg] = strdup(xval.addr);
     59 		if (XrmGetResource(xdb, "dmenu.hpforeground", "*", &type, &xval))
     60 			colors[SchemeHp][ColFg] = strdup(xval.addr);
     61 		#endif // HIGHPRIORITY_PATCH
     62 		#if EMOJI_HIGHLIGHT_PATCH
     63 		if (XrmGetResource(xdb, "dmenu.hoverbackground", "*", &type, &xval))
     64 			colors[SchemeHover][ColBg] = strdup(xval.addr);
     65 		if (XrmGetResource(xdb, "dmenu.hoverforeground", "*", &type, &xval))
     66 			colors[SchemeHover][ColFg] = strdup(xval.addr);
     67 		if (XrmGetResource(xdb, "dmenu.greenbackground", "*", &type, &xval))
     68 			colors[SchemeGreen][ColBg] = strdup(xval.addr);
     69 		if (XrmGetResource(xdb, "dmenu.greenforeground", "*", &type, &xval))
     70 			colors[SchemeGreen][ColFg] = strdup(xval.addr);
     71 		if (XrmGetResource(xdb, "dmenu.yellowbackground", "*", &type, &xval))
     72 			colors[SchemeYellow][ColBg] = strdup(xval.addr);
     73 		if (XrmGetResource(xdb, "dmenu.yellowforeground", "*", &type, &xval))
     74 			colors[SchemeYellow][ColFg] = strdup(xval.addr);
     75 		if (XrmGetResource(xdb, "dmenu.bluebackground", "*", &type, &xval))
     76 			colors[SchemeBlue][ColBg] = strdup(xval.addr);
     77 		if (XrmGetResource(xdb, "dmenu.blueforeground", "*", &type, &xval))
     78 			colors[SchemeBlue][ColFg] = strdup(xval.addr);
     79 		if (XrmGetResource(xdb, "dmenu.purplebackground", "*", &type, &xval))
     80 			colors[SchemePurple][ColBg] = strdup(xval.addr);
     81 		if (XrmGetResource(xdb, "dmenu.purpleforeground", "*", &type, &xval))
     82 			colors[SchemePurple][ColFg] = strdup(xval.addr);
     83 		if (XrmGetResource(xdb, "dmenu.redbackground", "*", &type, &xval))
     84 			colors[SchemeRed][ColBg] = strdup(xval.addr);
     85 		if (XrmGetResource(xdb, "dmenu.redforeground", "*", &type, &xval))
     86 			colors[SchemeRed][ColFg] = strdup(xval.addr);
     87 		#endif // EMOJI_HIGHLIGHT_PATCH
     88 		#if VI_MODE_PATCH
     89 		if (XrmGetResource(xdb, "dmenu.cursorbackground", "*", &type, &xval))
     90 			colors[SchemeCursor][ColBg] = strdup(xval.addr);
     91 		if (XrmGetResource(xdb, "dmenu.cursorforeground", "*", &type, &xval))
     92 			colors[SchemeCursor][ColFg] = strdup(xval.addr);
     93 		#endif // VI_MODE_PATCH
     94 		#if CARET_SCHEME_PATCH
     95 		if (XrmGetResource(xdb, "dmenu.caretbackground", "*", &type, &xval))
     96 			colors[SchemeCaret][ColBg] = strdup(xval.addr);
     97 		if (XrmGetResource(xdb, "dmenu.caretforeground", "*", &type, &xval))
     98 			colors[SchemeCaret][ColFg] = strdup(xval.addr);
     99 		#endif // CARET_SCHEME_PATCH
    100 		XrmDestroyDatabase(xdb);
    101 	}
    102 }