summaryrefslogtreecommitdiff
path: root/dmenu.c
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-02-26 00:54:14 -0600
committerzachir <zachir@librem.one>2023-02-26 00:54:14 -0600
commit8d1137d102c34626b33470f06dfca2bb63697062 (patch)
tree8ab357b3fd9036f8f7b479e300e5e7a89891912a /dmenu.c
parentb68278a760117d5595019a9f52e92fe9ceeb1d4a (diff)
Revert "add xresources patch (and fix with fuzzyhighlight)"noxresources
This reverts commit c6e51f44ae152c57a07ab9309b0ee8ae3cf7de74.
Diffstat (limited to 'dmenu.c')
-rw-r--r--dmenu.c108
1 files changed, 12 insertions, 96 deletions
diff --git a/dmenu.c b/dmenu.c
index e2018f3..f890c95 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -16,7 +16,6 @@
#include <X11/extensions/Xinerama.h>
#endif
#include <X11/Xft/Xft.h>
-#include <X11/Xresource.h>
#include "drw.h"
#include "util.h"
@@ -62,10 +61,6 @@ static XIC xic;
static Drw *drw;
static Clr *scheme[SchemeLast];
-/* Temporary arrays to allow overriding xresources values */
-static char *colortemp[8];
-static char *tempfonts;
-
#include "config.h"
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
@@ -923,13 +918,8 @@ setup(void)
int a, di, n, area = 0;
#endif
/* init appearance */
- for (j = 0; j < SchemeLast; j++) {
- 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]);
- }
+ for (j = 0; j < SchemeLast; j++)
+ scheme[j] = drw_scm_create(drw, colors[j], 2);
clip = XInternAtom(dpy, "CLIPBOARD", False);
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
@@ -1041,57 +1031,6 @@ usage(void)
" [-d separator] [-D separator]");
}
-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]);
- if (XrmGetResource(xdb, "dmenu.hibackground", "*", &type, &xval))
- colors[SchemeNormHighlight][ColBg] = strdup(xval.addr);
- else
- colors[SchemeNormHighlight][ColBg] = strdup(colors[SchemeSel][ColFg]);
- if (XrmGetResource(xdb, "dmenu.hiforeground", "*", &type, &xval))
- colors[SchemeNormHighlight][ColFg] = strdup(xval.addr);
- else
- colors[SchemeNormHighlight][ColFg] = strdup(colors[SchemeSel][ColFg]);
- if (XrmGetResource(xdb, "dmenu.selhibackground", "*", &type, &xval))
- colors[SchemeSelHighlight][ColBg] = strdup(xval.addr);
- else
- colors[SchemeSelHighlight][ColBg] = strdup(colors[SchemeSel][ColFg]);
- if (XrmGetResource(xdb, "dmenu.selhiforeground", "*", &type, &xval))
- colors[SchemeSelHighlight][ColFg] = strdup(xval.addr);
- else
- colors[SchemeSelHighlight][ColFg] = strdup(colors[SchemeSel][ColFg]);
-
- XrmDestroyDatabase(xdb);
- }
-}
-
int
main(int argc, char *argv[])
{
@@ -1132,23 +1071,23 @@ main(int argc, char *argv[])
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
prompt = argv[++i];
else if (!strcmp(argv[i], "-fn")) /* font or font set */
- tempfonts = argv[++i];
+ fonts[0] = argv[++i];
else if (!strcmp(argv[i], "-nb")) /* normal background color */
- colortemp[0] = argv[++i];
+ colors[SchemeNorm][ColBg] = argv[++i];
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
- colortemp[1] = argv[++i];
+ colors[SchemeNorm][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-sb")) /* selected background color */
- colortemp[2] = argv[++i];
+ colors[SchemeSel][ColBg] = argv[++i];
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
- colortemp[3] = argv[++i];
+ colors[SchemeSel][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-nhb")) /* normal hi background color */
- colortemp[4] = argv[++i];
+ colors[SchemeNormHighlight][ColBg] = argv[++i];
else if (!strcmp(argv[i], "-nhf")) /* normal hi foreground color */
- colortemp[5] = argv[++i];
+ colors[SchemeNormHighlight][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-shb")) /* selected hi background color */
- colortemp[6] = argv[++i];
+ colors[SchemeSelHighlight][ColBg] = argv[++i];
else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */
- colortemp[7] = argv[++i];
+ colors[SchemeSelHighlight][ColFg] = argv[++i];
else if (!strcmp(argv[i], "-w")) /* embedding window id */
embed = argv[++i];
else if (!strcmp(argv[i], "-bw"))
@@ -1174,31 +1113,8 @@ main(int argc, char *argv[])
die("could not get embedding window attributes: 0x%lx",
parentwin);
drw = drw_create(dpy, screen, root, wa.width, wa.height);
- readxresources();
- /* Now we check whether to override xresources with commandline parameters */
- if ( tempfonts )
- fonts[0] = strdup(tempfonts);
- if ( colortemp[0])
- colors[SchemeNorm][ColBg] = strdup(colortemp[0]);
- if ( colortemp[1])
- colors[SchemeNorm][ColFg] = strdup(colortemp[1]);
- if ( colortemp[2])
- colors[SchemeSel][ColBg] = strdup(colortemp[2]);
- if ( colortemp[3])
- colors[SchemeSel][ColFg] = strdup(colortemp[3]);
- if ( colortemp[4])
- colors[SchemeNormHighlight][ColBg] = strdup(colortemp[4]);
- if ( colortemp[5])
- colors[SchemeNormHighlight][ColFg] = strdup(colortemp[5]);
- if ( colortemp[6])
- colors[SchemeSelHighlight][ColBg] = strdup(colortemp[6]);
- if ( colortemp[7])
- colors[SchemeSelHighlight][ColFg] = strdup(colortemp[7]);
-
- if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts)))
+ if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
die("no fonts could be loaded.");
-
- free(fonts[0]);
lrpad = drw->fonts->h;
#ifdef __OpenBSD__