From 6ff3590af0cdf188c48ce952b276f24557f56d12 Mon Sep 17 00:00:00 2001 From: zachir Date: Fri, 24 Jun 2022 01:42:16 -0500 Subject: dmenu: reconfigure, update to upstream dmenu 5.1 --- dmenu.c | 500 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 254 insertions(+), 246 deletions(-) (limited to 'dmenu.c') diff --git a/dmenu.c b/dmenu.c index 0f4d6b4..d304e3a 100644 --- a/dmenu.c +++ b/dmenu.c @@ -16,6 +16,7 @@ #include #endif #include +#include #include "drw.h" #include "util.h" @@ -23,32 +24,19 @@ /* macros */ #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ * MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) -#define INTERSECTBOOL(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ +#define BOOL_INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ && MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) #define LENGTH(X) (sizeof X / sizeof X[0]) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) /* enums */ -enum { - SchemeNorm, - SchemeFade, - SchemeHighlight, - SchemeHover, - SchemeSel, - SchemeNormHighlight, - SchemeSelHighlight, - SchemeOut, - SchemeGreen, - SchemeYellow, - SchemeBlue, - SchemePurple, - SchemeRed, - SchemeLast -}; /* color schemes */ +enum { SchemeNorm, SchemeSel, SchemeNormHighlight, SchemeSelHighlight, + SchemeOut, SchemeLast }; /* color schemes */ + struct item { char *text; - char *text_output; + char *text_output; struct item *left, *right; int out; double distance; @@ -60,9 +48,6 @@ static char separator; static int separator_greedy; static int separator_reverse; static int bh, mw, mh; -static int dmx = 0; /* put dmenu at this x offset */ -static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */ -static unsigned int dmw = 0; /* make dmenu this wide */ static int inputw = 0, promptw, passwd = 0; static int lrpad; /* sum of left and right padding */ static int reject_no_match = 0; @@ -80,11 +65,14 @@ static XIC xic; static Drw *drw; static Clr *scheme[SchemeLast]; +/* Temporary arrays to allow overriding xresources values */ +static char *colortemp[4]; +static char *tempfonts; + #include "config.h" -static char * cistrstr(const char *s, const char *sub); -static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp; -static char *(*fstrstr)(const char *, const char *) = cistrstr; +static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; +static char *(*fstrstr)(const char *, const char *) = strstr; static void appenditem(struct item *item, struct item **list, struct item **last) @@ -140,170 +128,76 @@ cleanup(void) } static char * -cistrstr(const char *s, const char *sub) +cistrstr(const char *h, const char *n) { - size_t len; + size_t i; - for (len = strlen(sub); *s; s++) - if (!strncasecmp(s, sub, len)) - return (char *)s; + if (!n[0]) + return (char *)h; + + for (; *h; ++h) { + for (i = 0; n[i] && tolower((unsigned char)n[i]) == + tolower((unsigned char)h[i]); ++i) + ; + if (n[i] == '\0') + return (char *)h; + } return NULL; } static void drawhighlights(struct item *item, int x, int y, int maxw) { - int i, indent; - char *highlight; - char c; - - if (!(strlen(item->text) && strlen(text))) - return; - - drw_setscheme(drw, scheme[item == sel - ? SchemeSelHighlight - : SchemeNormHighlight]); - - for (i = 0, highlight = item->text; *highlight && text[i];) { - if (*highlight == text[i]) { - /* get indentation */ - c = *highlight; - *highlight = '\0'; - indent = TEXTW(item->text); - *highlight = c; - - /* highlight character */ - c = highlight[1]; - highlight[1] = '\0'; - drw_text( - drw, - x + indent - (lrpad / 2), - y, - MIN(maxw - indent, TEXTW(highlight) - lrpad), - bh, 0, highlight, 0 - ); - highlight[1] = c; - i++; - } - highlight++; - } + int i, indent; + char *highlight; + char c; + + if (!(strlen(item->text) && strlen(text))) + return; + + drw_setscheme(drw, scheme[item == sel + ? SchemeSelHighlight + : SchemeNormHighlight]); + for (i = 0, highlight = item->text; *highlight && text[i];) { + if (!fstrncmp(&(*highlight), &text[i], 1)) { + /* get indentation */ + c = *highlight; + *highlight = '\0'; + indent = TEXTW(item->text); + *highlight = c; + + /* highlight character */ + c = highlight[1]; + highlight[1] = '\0'; + drw_text( + drw, + x + indent - (lrpad / 2), + y, + MIN(maxw - indent, TEXTW(highlight) - lrpad), + bh, 0, highlight, 0 + ); + highlight[1] = c; + i++; + } + highlight++; + } } + static int -drawitem(struct item *item, int x, int y, int w) { - int r; - int iscomment = 0; - if (item->text[0] == '>') { - if (item->text[1] == '>') { - iscomment = 3; - switch (item->text[2]) { - case 'r': - drw_setscheme(drw, scheme[SchemeRed]); - break; - case 'g': - drw_setscheme(drw, scheme[SchemeGreen]); - break; - case 'y': - drw_setscheme(drw, scheme[SchemeYellow]); - break; - case 'b': - drw_setscheme(drw, scheme[SchemeBlue]); - break; - case 'p': - drw_setscheme(drw, scheme[SchemePurple]); - break; - case 'h': - drw_setscheme(drw, scheme[SchemeHighlight]); - break; - case 's': - drw_setscheme(drw, scheme[SchemeSel]); - break; - default: - iscomment = 1; - drw_setscheme(drw, scheme[SchemeNorm]); - break; - } - } else { - drw_setscheme(drw, scheme[SchemeNorm]); - iscomment = 1; - } - - } else if (item->text[0] == ':') { - iscomment = 2; - if (item == sel) { - switch (item->text[1]) { - case 'r': - drw_setscheme(drw, scheme[SchemeRed]); - break; - case 'g': - drw_setscheme(drw, scheme[SchemeGreen]); - break; - case 'y': - drw_setscheme(drw, scheme[SchemeYellow]); - break; - case 'b': - drw_setscheme(drw, scheme[SchemeBlue]); - break; - case 'p': - drw_setscheme(drw, scheme[SchemePurple]); - break; - case 'h': - drw_setscheme(drw, scheme[SchemeHighlight]); - break; - case 's': - drw_setscheme(drw, scheme[SchemeSel]); - break; - default: - drw_setscheme(drw, scheme[SchemeSel]); - iscomment = 0; - break; - } - } else { - drw_setscheme(drw, scheme[SchemeNorm]); - } - } else { - if (item == sel) - drw_setscheme(drw, scheme[SchemeSel]); - else if (item->out) - drw_setscheme(drw, scheme[SchemeOut]); - else - drw_setscheme(drw, scheme[SchemeNorm]); - } - - int temppadding; - temppadding = 0; - if (iscomment == 2) { - if (item->text[2] == ' ') { - temppadding = drw->fonts->h * 3; - animated = 1; - char dest[1000]; - strcpy(dest, item->text); - dest[6] = '\0'; - drw_text(drw, x, y, temppadding, lineheight, temppadding / 2.6, dest + 3, 0); - iscomment = 6; - drw_setscheme(drw, sel == item ? scheme[SchemeHover] : scheme[SchemeNorm]); - } - } - - char *output; - if (commented) { - static char onestr[2]; - onestr[0] = item->text[0]; - onestr[1] = '\0'; - output = onestr; - } else { - output = item->text; - } - - if (item == sel) - sely = y; - r = drw_text( - drw, x + ((iscomment == 6) ? temppadding : 0), y, - commented ? bh : (w - ((iscomment == 6) ? temppadding : 0)), bh, - commented ? (bh - drw_fontset_getwidth(drw, (output))) / 2 : lrpad / 2, - output + iscomment, 0); - drawhighlights(item, x, y, w); - return r; +drawitem(struct item *item, int x, int y, int w) +{ + int r; + if (item == sel) + drw_setscheme(drw, scheme[SchemeSel]); + else if (item->out) + drw_setscheme(drw, scheme[SchemeOut]); + else + drw_setscheme(drw, scheme[SchemeNorm]); + + r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0); + drawhighlights(item, x, y, w); + return r; } static void @@ -645,9 +539,11 @@ keypress(XKeyEvent *ev) utf8, utf8, win, CurrentTime); return; case XK_Left: + case XK_KP_Left: movewordedge(-1); goto draw; case XK_Right: + case XK_KP_Right: movewordedge(+1); goto draw; case XK_Return: @@ -685,6 +581,7 @@ insert: insert(buf, len); break; case XK_Delete: + case XK_KP_Delete: if (text[cursor] == '\0') return; cursor = nextrune(+1); @@ -695,6 +592,7 @@ insert: insert(NULL, nextrune(-1) - cursor); break; case XK_End: + case XK_KP_End: if (text[cursor] != '\0') { cursor = strlen(text); break; @@ -714,6 +612,7 @@ insert: cleanup(); exit(1); case XK_Home: + case XK_KP_Home: if (sel == matches) { cursor = 0; break; @@ -722,6 +621,7 @@ insert: calcoffsets(); break; case XK_Left: + case XK_KP_Left: if (cursor > 0 && (!sel || !sel->left || lines > 0)) { cursor = nextrune(-1); break; @@ -730,18 +630,21 @@ insert: return; /* fallthrough */ case XK_Up: + case XK_KP_Up: if (sel && sel->left && (sel = sel->left)->right == curr) { curr = prev; calcoffsets(); } break; case XK_Next: + case XK_KP_Next: if (!next) return; sel = curr = next; calcoffsets(); break; case XK_Prior: + case XK_KP_Prior: if (!prev) return; sel = curr = prev; @@ -758,6 +661,7 @@ insert: sel->out = 1; break; case XK_Right: + case XK_KP_Right: if (text[cursor] != '\0') { cursor = nextrune(+1); break; @@ -766,6 +670,7 @@ insert: return; /* fallthrough */ case XK_Down: + case XK_KP_Down: if (sel && sel->right && (sel = sel->right) == next) { curr = next; calcoffsets(); @@ -839,8 +744,11 @@ buttonpress(XEvent *e) } if (ev->button != Button1) return; + /* disabled below, needs to be fixed */ + /* if (ev->state & ~ControlMask) return; + */ if (lines > 0) { /* vertical list: (ctrl)left-click on item */ w = mw - x; @@ -898,6 +806,40 @@ buttonpress(XEvent *e) } } +static void +mousemove(XEvent *e) +{ + struct item *item; + XPointerMovedEvent *ev = &e->xmotion; + int x = 0, y = 0, h = bh, w; + + if (lines > 0) { + w = mw - x; + for (item = curr; item != next; item = item->right) { + y += h; + if (ev->y >= y && ev->y <= (y + h)) { + sel = item; + calcoffsets(); + drawmenu(); + return; + } + } + } else if (matches) { + x += inputw; + w = TEXTW("<"); + for (item = curr; item != next; item = item->right) { + x += w; + w = MIN(TEXTW(item->text), mw - x - TEXTW(">")); + if (ev->x >= x && ev->x <= x + w) { + sel = item; + calcoffsets(); + drawmenu(); + return; + } + } + } +} + static void paste(void) { @@ -937,17 +879,17 @@ readstdin(void) *p = '\0'; if (!(items[i].text = strdup(buf))) die("cannot strdup %u bytes:", strlen(buf) + 1); - if (separator && (p = (separator_greedy) ? - strrchr(items[i].text, separator) : strchr(items[i].text, separator))) { + if (separator && (p = separator_greedy ? + strrchr(items[i].text, separator) : strchr(items[i].text, separator))) { *p = '\0'; items[i].text_output = ++p; } else { items[i].text_output = items[i].text; } if (separator_reverse) { - char *tmp = items[i].text; + p = items[i].text; items[i].text = items[i].text_output; - items[i].text_output = tmp; + items[i].text_output = p; } items[i].out = 0; drw_font_getexts(drw->fonts, buf, strlen(buf), &tmpmax, NULL); @@ -979,6 +921,9 @@ run(void) case ButtonPress: buttonpress(&ev); break; + case MotionNotify: + mousemove(&ev); + break; case Expose: if (ev.xexpose.count == 0) drw_map(drw, win, 0, 0, mw, mh); @@ -1019,8 +964,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(colors[j][i]); + } clip = XInternAtom(dpy, "CLIPBOARD", False); utf8 = XInternAtom(dpy, "UTF8_STRING", False); @@ -1054,18 +1004,19 @@ setup(void) /* no focused window is on screen, so use pointer location instead */ if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du)) for (i = 0; i < n; i++) - if (INTERSECTBOOL(x, y, 1, 1, info[i])) + if (BOOL_INTERSECT(x, y, 1, 1, info[i])) break; - if (centered) { - mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width); - x = info[i].x_org + ((info[i].width - mw) / 2); - y = info[i].y_org + ((info[i].height - mh) / 2); - } else { - x = info[i].x_org; - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); - mw = info[i].width; - } + if (centered) { + mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width); + x = info[i].x_org + ((info[i].width - mw) / 2); + y = info[i].y_org + ((info[i].height - mh) / 2); + } else { + x = info[i].x_org; + y = info[i].y_org + (topbar ? 0 : info[i].height - mh); + mw = info[i].width; + } + XFree(info); } else #endif @@ -1073,15 +1024,16 @@ setup(void) if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); - if (centered) { - mw = MIN(MAX(max_textw() + promptw, min_width), wa.width); - x = (wa.width - mw) / 2; - y = (wa.height - mh) / 2; - } else { - x = dmx; - y = topbar ? dmy : wa.height - mh; - mw = wa.width; - } + + if (centered) { + mw = MIN(MAX(max_textw() + promptw, min_width), wa.width); + x = (wa.width - mw) / 2; + y = (wa.height - mh) / 2; + } else { + x = 0; + y = topbar ? 0 : wa.height - mh; + mw = wa.width; + } } inputw = MIN(inputw, mw/3); match(); @@ -1090,12 +1042,12 @@ setup(void) swa.override_redirect = True; swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | - ButtonPressMask; + ButtonPressMask | PointerMotionMask; win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); - if (border_width) - XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); + if (border_width) + XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); XSetClassHint(dpy, win, &ch); @@ -1123,13 +1075,64 @@ setup(void) static void usage(void) { - fputs("usage: dmenu [-bfsrvP] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n" - " [-x xoffset] [-y yoffset] [-z width] [-nb color] [-nf color] [-sb color] [-sf color]\n" - " [-nhb color] [-nhf color] [-shb color] [-shf color] [-w windowid]\n" + fputs("usage: dmenu [-bfirvP] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-nb color] [-nf color] [-sb color] [-sf color] [-bw width]\n" + " [-nhb color] [-nhf color] [-shb color] [-shf color] [-w windowid]\n" " [-d separator] [-D separator]\n", stderr); 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.selhibackground", "*", &type, &xval)) + colors[SchemeSelHighlight][ColBg] = strdup(xval.addr); + else + colors[SchemeSelHighlight][ColBg] = strdup(colors[SchemeSel][ColBg]); + if (XrmGetResource(xdb, "dmenu.selhiforeground", "*", &type, &xval)) + colors[SchemeSelHighlight][ColFg] = strdup(xval.addr); + else + colors[SchemeSelHighlight][ColFg] = strdup(colors[SchemeSel][ColFg]); + if (XrmGetResource(xdb, "dmenu.hibackground", "*", &type, &xval)) + colors[SchemeNormHighlight][ColBg] = strdup(xval.addr); + else + colors[SchemeNormHighlight][ColBg] = strdup(colors[SchemeNorm][ColBg]); + if (XrmGetResource(xdb, "dmenu.hiforeground", "*", &type, &xval)) + colors[SchemeNormHighlight][ColFg] = strdup(xval.addr); + else + colors[SchemeNormHighlight][ColFg] = strdup(colors[SchemeNorm][ColFg]); + + XrmDestroyDatabase(xdb); + } +} + int main(int argc, char *argv[]) { @@ -1145,28 +1148,22 @@ 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")) /* is not fuzzy search */ - fuzzy = 0; else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */ centered = 1; - else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */ - fstrncmp = strncmp; - fstrstr = strstr; - } else if (!strcmp(argv[i], "-r")) /* reject input which results in no match */ + else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */ + fuzzy = 1; + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; + } else if (!strcmp(argv[i], "-P")) /* is the input a password */ + passwd = 1; + else if (!strcmp(argv[i], "-r")) /* reject input which results in no match */ reject_no_match = 1; - else if (!strcmp(argv[i], "-P")) /* is the input a password */ - passwd = 1; else if (i + 1 == argc) usage(); /* these options take one argument */ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); - else if (!strcmp(argv[i], "-x")) /* window x offset */ - dmx = atoi(argv[++i]); - else if (!strcmp(argv[i], "-y")) /* window x offset */ - dmy = atoi(argv[++i]); - else if (!strcmp(argv[i], "-z")) /* window x offset */ - dmw = atoi(argv[++i]); else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */ lineheight = atoi(argv[++i]); lineheight = MAX(lineheight, min_lineheight); @@ -1176,32 +1173,31 @@ 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]; - else if (!strcmp(argv[i], "-nhb")) /* normal hi background color */ - colors[SchemeNormHighlight][ColBg] = argv[++i]; - else if (!strcmp(argv[i], "-nhf")) /* normal hi foreground color */ - colors[SchemeNormHighlight][ColFg] = argv[++i]; - else if (!strcmp(argv[i], "-shb")) /* selected hi background color */ - colors[SchemeSelHighlight][ColBg] = argv[++i]; - else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */ - colors[SchemeSelHighlight][ColFg] = argv[++i]; + colortemp[3] = argv[++i]; + else if (!strcmp(argv[i], "-nhb")) /* normal hi background color */ + colors[SchemeNormHighlight][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-nhf")) /* normal hi foreground color */ + colors[SchemeNormHighlight][ColFg] = argv[++i]; + else if (!strcmp(argv[i], "-shb")) /* selected hi background color */ + colors[SchemeSelHighlight][ColBg] = argv[++i]; + else if (!strcmp(argv[i], "-shf")) /* selected hi foreground color */ + colors[SchemeSelHighlight][ColFg] = argv[++i]; else if (!strcmp(argv[i], "-w")) /* embedding window id */ embed = argv[++i]; - else if (!strcmp(argv[i], "-bw")) /* border width */ - border_width = atoi(argv[++i]); - else if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "-D")) { /* field separator */ - separator_reverse = (*(argv[i+1]+1) == '|'); - separator_greedy = !strcmp(argv[i], "-D"); - separator = *argv[++i]; - } + else if (!strcmp(argv[i], "-d") || /* field separator */ + (separator_greedy = !strcmp(argv[i], "-D"))) { + separator = argv[++i][0]; + separator_reverse = argv[i][1] == '|'; + } else if (!strcmp(argv[i], "-bw")) + border_width = atoi(argv[++i]); /* border width */ else usage(); @@ -1217,12 +1213,24 @@ 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 (!drw_fontset_create(drw, (const char**)fonts, LENGTH(fonts))) die("no fonts could be loaded."); - lrpad = drw->fonts->h; - if (lineheight == -1) - lineheight = drw->fonts->h * 2.5; + free(fonts[0]); + lrpad = drw->fonts->h; #ifdef __OpenBSD__ if (pledge("stdio rpath", NULL) == -1) -- cgit v1.2.3