aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2022-03-17 22:07:02 -0400
committertdro <tdro@users.noreply.github.com>2022-03-17 22:07:02 -0400
commit7359d5e8a20073a9e40f92c6ad37d61ed5326859 (patch)
tree7d76b1c0bedf6d919926adac2bdc730178d8ead6
parent3a505cebe8adab204e5619357e0bfe3f9f3a92ff (diff)
downloaddmenu-7359d5e8a20073a9e40f92c6ad37d61ed5326859.tar.gz
dmenu-7359d5e8a20073a9e40f92c6ad37d61ed5326859.tar.bz2
dmenu-7359d5e8a20073a9e40f92c6ad37d61ed5326859.zip
Makefile: Add patches and shell environment
-rw-r--r--Makefile3
-rw-r--r--patches/compact.patch153
-rw-r--r--patches/fuzzymatch.patch163
-rw-r--r--patches/highlight.patch94
-rw-r--r--patches/instantexit.patch17
-rw-r--r--patches/xresources.patch158
-rw-r--r--shell.nix28
7 files changed, 615 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a03a95c..e6d5def 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,8 @@ stest: stest.o
$(CC) -o $@ stest.o $(LDFLAGS)
clean:
- rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
+ rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz config.h
+ git checkout config.def.h config.mk dmenu.c drw.c
dist: clean
mkdir -p dmenu-$(VERSION)
diff --git a/patches/compact.patch b/patches/compact.patch
new file mode 100644
index 0000000..f7013b7
--- /dev/null
+++ b/patches/compact.patch
@@ -0,0 +1,153 @@
+diff --git a/dmenu.c b/dmenu.c
+index 77f424d..4c841d8 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -81,19 +81,6 @@ appenditem(struct item *item, struct item **list, struct item **last)
+ static void
+ calcoffsets(void)
+ {
+- int i, n;
+-
+- if (lines > 0)
+- n = lines * bh;
+- else
+- n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
+- /* calculate which items will begin the next page and previous page */
+- for (i = 0, next = curr; next; next = next->right)
+- if ((i += (lines > 0) ? bh : MIN(TEXTW(next->text), n)) > n)
+- break;
+- for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
+- if ((i += (lines > 0) ? bh : MIN(TEXTW(prev->left->text), n)) > n)
+- break;
+ }
+
+ static void
+@@ -148,10 +135,10 @@ drawhighlights(struct item *item, int x, int y, int maxw)
+ // Move highlight str end, draw highlight, & restore
+ restorechar = highlight[strlen(token)];
+ highlight[strlen(token)] = '\0';
+- if (indentx - (lrpad / 2) - 1 < maxw)
++ if (indentx - lrpad - 1 < maxw)
+ drw_text(
+ drw,
+- x + indentx - (lrpad / 2) - 1,
++ x + indentx - lrpad - 1,
+ y,
+ MIN(maxw - indentx, TEXTW(highlight) - lrpad),
+ bh, 0, highlight, 0
+@@ -174,7 +161,7 @@ drawitem(struct item *item, int x, int y, int w)
+ else
+ drw_setscheme(drw, scheme[SchemeNorm]);
+
+- int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ int r = drw_text(drw, x, y, w, bh, lrpad, item->text, 0);
+ drawhighlights(item, x, y, w);
+ return r;
+ }
+@@ -182,7 +169,6 @@ drawitem(struct item *item, int x, int y, int w)
+ static void
+ drawmenu(void)
+ {
+- unsigned int curpos;
+ struct item *item;
+ int x = 0, y = 0, w;
+
+@@ -191,17 +177,7 @@ drawmenu(void)
+
+ if (prompt && *prompt) {
+ drw_setscheme(drw, scheme[SchemeSel]);
+- x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
+- }
+- /* draw input field */
+- w = (lines > 0 || !matches) ? mw - x : inputw;
+- drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
+-
+- curpos = TEXTW(text) - TEXTW(&text[cursor]);
+- if ((curpos += lrpad / 2 - 1) < w) {
+- drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
++ x = drw_text(drw, x, 0, promptw, bh, lrpad, prompt, 0);
+ }
+
+ if (lines > 0) {
+@@ -211,18 +187,18 @@ drawmenu(void)
+ } else if (matches) {
+ /* draw horizontal list */
+ x += inputw;
+- w = TEXTW("<");
++ w = TEXTW("");
+ if (curr->left) {
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
++ drw_text(drw, x, 0, w, bh, lrpad, "", 0);
+ }
+ x += w;
+ for (item = curr; item != next; item = item->right)
+- x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW(">")));
++ x = drawitem(item, x, 0, MIN(TEXTW(item->text), mw - x - TEXTW("")));
+ if (next) {
+- w = TEXTW(">");
++ w = TEXTW("");
+ drw_setscheme(drw, scheme[SchemeNorm]);
+- drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
++ drw_text(drw, mw - w, 0, w, bh, lrpad, "", 0);
+ }
+ }
+ drw_map(drw, win, 0, 0, mw, mh);
+@@ -671,7 +647,7 @@ static void
+ readstdin(void)
+ {
+ char buf[sizeof text], *p;
+- size_t i, imax = 0, size = 0;
++ size_t i, size = 0;
+ unsigned int tmpmax = 0;
+
+ /* read each line from stdin and add it to the item list */
+@@ -687,12 +663,11 @@ readstdin(void)
+ drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL);
+ if (tmpmax > inputw) {
+ inputw = tmpmax;
+- imax = i;
+ }
+ }
+ if (items)
+ items[i].text = NULL;
+- inputw = items ? TEXTW(items[imax].text) : 0;
++ inputw = 0;
+ lines = MIN(lines, i);
+ }
+
+@@ -805,7 +780,7 @@ setup(void)
+ y = topbar ? 0 : wa.height - mh;
+ mw = wa.width;
+ }
+- promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
++ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad : 0;
+ inputw = MIN(inputw, mw/3);
+ match();
+
+@@ -972,7 +947,7 @@ main(int argc, char *argv[])
+ die("no fonts could be loaded.");
+
+ free((char *) fonts[0]);
+- lrpad = drw->fonts->h;
++ lrpad = 10;
+
+ #ifdef __OpenBSD__
+ if (pledge("stdio rpath", NULL) == -1)
+diff --git a/drw.c b/drw.c
+index 4cdbcbe..176ac37 100644
+--- a/drw.c
++++ b/drw.c
+@@ -277,8 +277,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
+ d = XftDrawCreate(drw->dpy, drw->drawable,
+ DefaultVisual(drw->dpy, drw->screen),
+ DefaultColormap(drw->dpy, drw->screen));
+- x += lpad;
+- w -= lpad;
++ x += 0;
++ w -= 0;
+ }
+
+ usedfont = drw->fonts;
diff --git a/patches/fuzzymatch.patch b/patches/fuzzymatch.patch
new file mode 100644
index 0000000..9fd206d
--- /dev/null
+++ b/patches/fuzzymatch.patch
@@ -0,0 +1,163 @@
+From 94353eb52055927d9079f3d9e33da1c954abf386 Mon Sep 17 00:00:00 2001
+From: aleks <aleks.stier@icloud.com>
+Date: Wed, 26 Jun 2019 13:25:10 +0200
+Subject: [PATCH] Add support for fuzzy-matching
+
+---
+ config.def.h | 1 +
+ config.mk | 2 +-
+ dmenu.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 91 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..51612b9 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -2,6 +2,7 @@
+ /* Default settings; can be overriden by command line. */
+
+ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
++static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */
+ /* -fn option overrides fonts[0]; default X11 font or font set */
+ static const char *fonts[] = {
+ "monospace:size=10"
+diff --git a/config.mk b/config.mk
+index 0929b4a..d14309a 100644
+--- a/config.mk
++++ b/config.mk
+@@ -20,7 +20,7 @@ FREETYPEINC = /usr/include/freetype2
+
+ # includes and libs
+ INCS = -I$(X11INC) -I$(FREETYPEINC)
+-LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS)
++LIBS = -L$(X11LIB) -lX11 $(XINERAMALIBS) $(FREETYPELIBS) -lm
+
+ # flags
+ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..96ddc98 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -1,6 +1,7 @@
+ /* See LICENSE file for copyright and license details. */
+ #include <ctype.h>
+ #include <locale.h>
++#include <math.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -32,6 +33,7 @@ struct item {
+ char *text;
+ struct item *left, *right;
+ int out;
++ double distance;
+ };
+
+ static char text[BUFSIZ] = "";
+@@ -210,9 +212,94 @@ grabkeyboard(void)
+ die("cannot grab keyboard");
+ }
+
++int
++compare_distance(const void *a, const void *b)
++{
++ struct item *da = *(struct item **) a;
++ struct item *db = *(struct item **) b;
++
++ if (!db)
++ return 1;
++ if (!da)
++ return -1;
++
++ return da->distance == db->distance ? 0 : da->distance < db->distance ? -1 : 1;
++}
++
++void
++fuzzymatch(void)
++{
++ /* bang - we have so much memory */
++ struct item *it;
++ struct item **fuzzymatches = NULL;
++ char c;
++ int number_of_matches = 0, i, pidx, sidx, eidx;
++ int text_len = strlen(text), itext_len;
++
++ matches = matchend = NULL;
++
++ /* walk through all items */
++ for (it = items; it && it->text; it++) {
++ if (text_len) {
++ itext_len = strlen(it->text);
++ pidx = 0; /* pointer */
++ sidx = eidx = -1; /* start of match, end of match */
++ /* walk through item text */
++ for (i = 0; i < itext_len && (c = it->text[i]); i++) {
++ /* fuzzy match pattern */
++ if (!fstrncmp(&text[pidx], &c, 1)) {
++ if(sidx == -1)
++ sidx = i;
++ pidx++;
++ if (pidx == text_len) {
++ eidx = i;
++ break;
++ }
++ }
++ }
++ /* build list of matches */
++ if (eidx != -1) {
++ /* compute distance */
++ /* add penalty if match starts late (log(sidx+2))
++ * add penalty for long a match without many matching characters */
++ it->distance = log(sidx + 2) + (double)(eidx - sidx - text_len);
++ /* fprintf(stderr, "distance %s %f\n", it->text, it->distance); */
++ appenditem(it, &matches, &matchend);
++ number_of_matches++;
++ }
++ } else {
++ appenditem(it, &matches, &matchend);
++ }
++ }
++
++ if (number_of_matches) {
++ /* initialize array with matches */
++ if (!(fuzzymatches = realloc(fuzzymatches, number_of_matches * sizeof(struct item*))))
++ die("cannot realloc %u bytes:", number_of_matches * sizeof(struct item*));
++ for (i = 0, it = matches; it && i < number_of_matches; i++, it = it->right) {
++ fuzzymatches[i] = it;
++ }
++ /* sort matches according to distance */
++ qsort(fuzzymatches, number_of_matches, sizeof(struct item*), compare_distance);
++ /* rebuild list of matches */
++ matches = matchend = NULL;
++ for (i = 0, it = fuzzymatches[i]; i < number_of_matches && it && \
++ it->text; i++, it = fuzzymatches[i]) {
++ appenditem(it, &matches, &matchend);
++ }
++ free(fuzzymatches);
++ }
++ curr = sel = matches;
++ calcoffsets();
++}
++
+ static void
+ match(void)
+ {
++ if (fuzzy) {
++ fuzzymatch();
++ return;
++ }
+ static char **tokv = NULL;
+ static int tokn = 0;
+
+@@ -702,6 +789,8 @@ main(int argc, char *argv[])
+ topbar = 0;
+ else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
+ fast = 1;
++ else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */
++ fuzzy = 0;
+ else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
+ fstrncmp = strncasecmp;
+ fstrstr = cistrstr;
+--
+2.22.0
+
diff --git a/patches/highlight.patch b/patches/highlight.patch
new file mode 100644
index 0000000..8eb784b
--- /dev/null
+++ b/patches/highlight.patch
@@ -0,0 +1,94 @@
+From a06d0d3d7bbb3c0f5bad44934dbbf1e88e7d9558 Mon Sep 17 00:00:00 2001
+From: Miles Alan <m@milesalan.com>
+Date: Sat, 4 Jul 2020 11:49:04 -0500
+Subject: [PATCH] Highlight matched text in a different color scheme
+
+---
+ config.def.h | 2 ++
+ dmenu.c | 43 +++++++++++++++++++++++++++++++++++++++++--
+ 2 files changed, 43 insertions(+), 2 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1edb647..64eab2a 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -11,6 +11,8 @@ static const char *colors[SchemeLast][2] = {
+ /* fg bg */
+ [SchemeNorm] = { "#bbbbbb", "#222222" },
+ [SchemeSel] = { "#eeeeee", "#005577" },
++ [SchemeSelHighlight] = { "#ffc978", "#005577" },
++ [SchemeNormHighlight] = { "#ffc978", "#222222" },
+ [SchemeOut] = { "#000000", "#00ffff" },
+ };
+ /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+diff --git a/dmenu.c b/dmenu.c
+index 6b8f51b..d5e1991 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -26,7 +26,7 @@
+ #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
+
+ /* enums */
+-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
++enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */
+
+ struct item {
+ char *text;
+@@ -113,6 +113,43 @@ cistrstr(const char *s, const char *sub)
+ return NULL;
+ }
+
++static void
++drawhighlights(struct item *item, int x, int y, int maxw)
++{
++ char restorechar, tokens[sizeof text], *highlight, *token;
++ int indentx, highlightlen;
++
++ drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
++ strcpy(tokens, text);
++ for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
++ highlight = fstrstr(item->text, token);
++ while (highlight) {
++ // Move item str end, calc width for highlight indent, & restore
++ highlightlen = highlight - item->text;
++ restorechar = *highlight;
++ item->text[highlightlen] = '\0';
++ indentx = TEXTW(item->text);
++ item->text[highlightlen] = restorechar;
++
++ // Move highlight str end, draw highlight, & restore
++ restorechar = highlight[strlen(token)];
++ highlight[strlen(token)] = '\0';
++ if (indentx - (lrpad / 2) - 1 < maxw)
++ drw_text(
++ drw,
++ x + indentx - (lrpad / 2) - 1,
++ y,
++ MIN(maxw - indentx, TEXTW(highlight) - lrpad),
++ bh, 0, highlight, 0
++ );
++ highlight[strlen(token)] = restorechar;
++
++ if (strlen(highlight) - strlen(token) < strlen(token)) break;
++ highlight = fstrstr(highlight + strlen(token), token);
++ }
++ }
++}
++
+ static int
+ drawitem(struct item *item, int x, int y, int w)
+ {
+@@ -123,7 +160,9 @@ drawitem(struct item *item, int x, int y, int w)
+ else
+ drw_setscheme(drw, scheme[SchemeNorm]);
+
+- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
++ drawhighlights(item, x, y, w);
++ return r;
+ }
+
+ static void
+--
+2.23.1
+
diff --git a/patches/instantexit.patch b/patches/instantexit.patch
new file mode 100644
index 0000000..74ca39c
--- /dev/null
+++ b/patches/instantexit.patch
@@ -0,0 +1,17 @@
+diff --git a/dmenu.c b/dmenu.c
+index 4c841d8..2d14dba 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -317,6 +317,12 @@ fuzzymatch(void)
+ free(fuzzymatches);
+ }
+ curr = sel = matches;
++
++ if (matches == NULL) {
++ cleanup();
++ exit(127);
++ }
++
+ calcoffsets();
+ }
+
diff --git a/patches/xresources.patch b/patches/xresources.patch
new file mode 100644
index 0000000..f2d048e
--- /dev/null
+++ b/patches/xresources.patch
@@ -0,0 +1,158 @@
+diff --git a/dmenu.c b/dmenu.c
+index eca67ac..902f67d 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -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"
+@@ -53,6 +54,10 @@ 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;
+@@ -619,8 +624,13 @@ setup(void)
+ int a, di, n, area = 0;
+ #endif
+ /* init appearance */
+- for (j = 0; j < SchemeLast; j++)
+- scheme[j] = drw_scm_create(drw, colors[j], 2);
++ 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((char *) colors[j][i]);
++ }
+
+ clip = XInternAtom(dpy, "CLIPBOARD", False);
+ utf8 = XInternAtom(dpy, "UTF8_STRING", False);
+@@ -712,6 +722,57 @@ usage(void)
+ 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]);
++ if (XrmGetResource(xdb, "dmenu.selhiforeground", "*", &type, &xval))
++ colors[SchemeSelHighlight][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeSelHighlight][ColFg] = strdup(colors[SchemeSelHighlight][ColFg]);
++ if (XrmGetResource(xdb, "dmenu.selhibackground", "*", &type, &xval))
++ colors[SchemeSelHighlight][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeSelHighlight][ColBg] = strdup(colors[SchemeSelHighlight][ColBg]);
++ if (XrmGetResource(xdb, "dmenu.normhiforeground", "*", &type, &xval))
++ colors[SchemeNormHighlight][ColFg] = strdup(xval.addr);
++ else
++ colors[SchemeNormHighlight][ColFg] = strdup(colors[SchemeNormHighlight][ColFg]);
++ if (XrmGetResource(xdb, "dmenu.normhibackground", "*", &type, &xval))
++ colors[SchemeNormHighlight][ColBg] = strdup(xval.addr);
++ else
++ colors[SchemeNormHighlight][ColBg] = strdup(colors[SchemeNormHighlight][ColBg]);
++
++ XrmDestroyDatabase(xdb);
++ }
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -740,15 +801,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 */
+- fonts[0] = argv[++i];
++ tempfonts = argv[++i];
+ else if (!strcmp(argv[i], "-nb")) /* normal background color */
+- colors[SchemeNorm][ColBg] = argv[++i];
++ colortemp[0] = argv[++i];
+ else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
+- colors[SchemeNorm][ColFg] = argv[++i];
++ colortemp[1] = argv[++i];
+ else if (!strcmp(argv[i], "-sb")) /* selected background color */
+- colors[SchemeSel][ColBg] = argv[++i];
++ colortemp[2] = argv[++i];
+ else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
+- colors[SchemeSel][ColFg] = argv[++i];
++ colortemp[3] = argv[++i];
++ else if (!strcmp(argv[i], "-shf")) /* selected highlight foreground color */
++ colortemp[4] = argv[++i];
++ else if (!strcmp(argv[i], "-shb")) /* selected highlight background color */
++ colortemp[5] = argv[++i];
++ else if (!strcmp(argv[i], "-nhf")) /* normal highlight foreground color */
++ colortemp[6] = argv[++i];
++ else if (!strcmp(argv[i], "-nhb")) /* normal highlight background color */
++ colortemp[7] = argv[++i];
+ else if (!strcmp(argv[i], "-w")) /* embedding window id */
+ embed = argv[++i];
+ else
+@@ -766,8 +835,30 @@ 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);
+- if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
++ 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[SchemeSelHighlight][ColFg] = strdup(colortemp[4]);
++ if ( colortemp[5])
++ colors[SchemeSelHighlight][ColBg] = strdup(colortemp[5]);
++ if ( colortemp[6])
++ colors[SchemeNormHighlight][ColFg] = strdup(colortemp[6]);
++ if ( colortemp[7])
++ colors[SchemeNormHighlight][ColBg] = strdup(colortemp[7]);
++ if (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts)))
+ die("no fonts could be loaded.");
++
++ free((char *) fonts[0]);
+ lrpad = drw->fonts->h;
+
+ #ifdef __OpenBSD__
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..c54dd8a
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,28 @@
+let
+
+ name = "nix-shell.dmenu";
+
+ pkgs = import (builtins.fetchTarball {
+ url = "https://releases.nixos.org/nixos/21.11/nixos-21.11.336020.2128d0aa28e/nixexprs.tar.xz";
+ sha256 = "0w8plbxms0di6gnh0k2yhj0pgxzxas7g5x0m01zjzixf16i2bapj"; }) {};
+
+ mkShellMinimal = pkgs.callPackage (builtins.fetchurl {
+ url = "https://raw.githubusercontent.com/tdro/dotfiles/0aac4414559235f8cd8c454acce30c0471e0f6b1/.config/nixpkgs/helpers/mkShellMinimal.nix";
+ sha256 = "06vbyyhaam3nmzimzasz6la590ni9cbdql3jy29hhw9ln0xf09yy";
+ }) { };
+
+in mkShellMinimal rec {
+ buildInputs = [
+ pkgs.bash
+ pkgs.coreutils
+ pkgs.gcc
+ pkgs.git
+ pkgs.gnumake
+ pkgs.xlibs.libX11.dev
+ pkgs.xlibs.libXft.dev
+ pkgs.xlibs.libXinerama.dev
+ ];
+ shellHook = ''
+ export PS1='\h (${name}) \W \$ '
+ '';
+}