Compare commits
1 Commits
mydmenu
...
xresources
| Author | SHA1 | Date | |
|---|---|---|---|
| 64246c0e6d |
50
dmenu.c
50
dmenu.c
@ -15,6 +15,7 @@
|
|||||||
#include <X11/extensions/Xinerama.h>
|
#include <X11/extensions/Xinerama.h>
|
||||||
#endif
|
#endif
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
#include <X11/Xresource.h>
|
||||||
|
|
||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -601,8 +602,13 @@ setup(void)
|
|||||||
int a, di, n, area = 0;
|
int a, di, n, area = 0;
|
||||||
#endif
|
#endif
|
||||||
/* init appearance */
|
/* init appearance */
|
||||||
for (j = 0; j < SchemeLast; j++)
|
for (j = 0; j < SchemeLast; j++) {
|
||||||
scheme[j] = drw_scm_create(drw, colors[j], 2);
|
scheme[j] = drw_scm_create(drw, (const char**)colors[j], 2);
|
||||||
|
}
|
||||||
|
for (j = 0; j < SchemeOut; ++j) {
|
||||||
|
for (i = 0; i < 2; ++i)
|
||||||
|
free(colors[j][i]);
|
||||||
|
}
|
||||||
|
|
||||||
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||||
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
@ -694,6 +700,41 @@ usage(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
readxresources(void) {
|
||||||
|
XrmInitialize();
|
||||||
|
|
||||||
|
char* xrm;
|
||||||
|
if ((xrm = XResourceManagerString(drw->dpy))) {
|
||||||
|
char *type;
|
||||||
|
XrmDatabase xdb = XrmGetStringDatabase(xrm);
|
||||||
|
XrmValue xval;
|
||||||
|
|
||||||
|
if (XrmGetResource(xdb, "dmenu.font", "*", &type, &xval))
|
||||||
|
fonts[0] = strdup(xval.addr);
|
||||||
|
else
|
||||||
|
fonts[0] = strdup(fonts[0]);
|
||||||
|
if (XrmGetResource(xdb, "dmenu.background", "*", &type, &xval))
|
||||||
|
colors[SchemeNorm][ColBg] = strdup(xval.addr);
|
||||||
|
else
|
||||||
|
colors[SchemeNorm][ColBg] = strdup(colors[SchemeNorm][ColBg]);
|
||||||
|
if (XrmGetResource(xdb, "dmenu.foreground", "*", &type, &xval))
|
||||||
|
colors[SchemeNorm][ColFg] = strdup(xval.addr);
|
||||||
|
else
|
||||||
|
colors[SchemeNorm][ColFg] = strdup(colors[SchemeNorm][ColFg]);
|
||||||
|
if (XrmGetResource(xdb, "dmenu.selbackground", "*", &type, &xval))
|
||||||
|
colors[SchemeSel][ColBg] = strdup(xval.addr);
|
||||||
|
else
|
||||||
|
colors[SchemeSel][ColBg] = strdup(colors[SchemeSel][ColBg]);
|
||||||
|
if (XrmGetResource(xdb, "dmenu.selforeground", "*", &type, &xval))
|
||||||
|
colors[SchemeSel][ColFg] = strdup(xval.addr);
|
||||||
|
else
|
||||||
|
colors[SchemeSel][ColFg] = strdup(colors[SchemeSel][ColFg]);
|
||||||
|
|
||||||
|
XrmDestroyDatabase(xdb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -748,8 +789,11 @@ main(int argc, char *argv[])
|
|||||||
die("could not get embedding window attributes: 0x%lx",
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
parentwin);
|
parentwin);
|
||||||
drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
||||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
readxresources();
|
||||||
|
if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts)))
|
||||||
die("no fonts could be loaded.");
|
die("no fonts could be loaded.");
|
||||||
|
|
||||||
|
free(fonts[0]);
|
||||||
lrpad = drw->fonts->h;
|
lrpad = drw->fonts->h;
|
||||||
|
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user