Postfix + Customization
This commit is contained in:
parent
b8ba950645
commit
c9ad918fe8
|
@ -1,2 +1,3 @@
|
|||
PATCHES/*
|
||||
CUSTOM_PATCHING/*
|
||||
PATCHES*
|
||||
CUSTOM_PATCHING*
|
||||
config.def.h
|
||||
|
|
35
config.def.h
35
config.def.h
|
@ -1,44 +1,51 @@
|
|||
/* See LICENSE file for copyright and license details. */
|
||||
/* Default settings; can be overriden by command line. */
|
||||
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
static int centered = 0; /* -c option; centers dmenu on screen */
|
||||
static int min_width = 500; /* minimum width when centered */
|
||||
static int colorprompt = 1; /* -p option; if 1, prompt uses SchemeSel, otherwise SchemeNorm */
|
||||
static const unsigned int alpha = 0xf0;
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
static int centered = 0; /* -c option; centers dmenu on screen */
|
||||
static int colorprompt = 1; /* -p option; if 1, prompt uses SchemeSel, otherwise SchemeNorm */
|
||||
static int min_width = 480; /* minimum width when centered */
|
||||
static const unsigned int alpha = 0xD0;
|
||||
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
"Terminus:size=9"
|
||||
};
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
/* fg bg */
|
||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||
[SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||
[SchemeOut] = { "#000000", "#00ffff" },
|
||||
[SchemeNorm] = { "#a7acc5", "#2d0827" },
|
||||
[SchemeSel] = { "#f9f5e9", "#402c4e" },
|
||||
[SchemeSelHighlight] = { "#d93352", "#402c4e" },
|
||||
[SchemeNormHighlight] = { "#f15b94", "#2d0827" },
|
||||
[SchemeOut] = { "#2d0827", "#c7acc5" },
|
||||
};
|
||||
|
||||
static const unsigned int alphas[SchemeLast][2] = {
|
||||
[SchemeNorm] = { OPAQUE, alpha },
|
||||
[SchemeSel] = { OPAQUE, alpha },
|
||||
[SchemeOut] = { OPAQUE, alpha },
|
||||
[SchemeSelHighlight] = { OPAQUE, alpha },
|
||||
[SchemeNormHighlight] = { OPAQUE, alpha},
|
||||
};
|
||||
|
||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||
static unsigned int lines = 0;
|
||||
/* -h option; minimum height of a menu line */
|
||||
static unsigned int lineheight = 0;
|
||||
static unsigned int min_lineheight = 8;
|
||||
static unsigned int lineheight = 20;
|
||||
static unsigned int min_lineheight = 20;
|
||||
|
||||
/*
|
||||
* Characters not considered part of a word while deleting words
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
static const char worddelimiters[] = " /?\"&[]";
|
||||
|
||||
/* -n option; preselected item starting from 0 */
|
||||
static unsigned int preselected = 0;
|
||||
/* Size of the window border */
|
||||
static unsigned int border_width = 0;
|
||||
/* tsv-alt: reverse the order of tab separation.
|
||||
* 0 = display<TAB>output. 1 = output<TAB>display
|
||||
* can be reversed with -r as well */
|
||||
static int revtab = 0;
|
||||
|
|
|
@ -21,7 +21,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) -lXrender
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
|
||||
|
|
5
dmenu.1
5
dmenu.1
|
@ -3,7 +3,7 @@
|
|||
dmenu \- dynamic menu
|
||||
.SH SYNOPSIS
|
||||
.B dmenu
|
||||
.RB [ \-bfsv ]
|
||||
.RB [ \-bfivr ]
|
||||
.RB [ \-l
|
||||
.IR lines ]
|
||||
.RB [ \-h
|
||||
|
@ -120,6 +120,9 @@ embed into windowid.
|
|||
.TP
|
||||
.BI \-n " number"
|
||||
preseslected item starting from 0.
|
||||
.TP
|
||||
.B \-r
|
||||
tsv-alt: reverse the behavior of tab separation.
|
||||
.SH USAGE
|
||||
dmenu is completely controlled by the keyboard. Items are selected using the
|
||||
arrow keys, page up, page down, home, and end.
|
||||
|
|
59
dmenu.c
59
dmenu.c
|
@ -36,7 +36,7 @@ enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight
|
|||
|
||||
struct item {
|
||||
char *text;
|
||||
char *stext;
|
||||
char *otext;
|
||||
struct item *left, *right;
|
||||
int out;
|
||||
};
|
||||
|
@ -45,10 +45,10 @@ static char numbers[NUMBERSBUFSIZE] = "";
|
|||
static char text[BUFSIZ] = "";
|
||||
static char *embed;
|
||||
static int bh, mw, mh;
|
||||
static int inputw = 64, promptw;
|
||||
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;
|
||||
static int lrpad; /* sum of left and right padding */
|
||||
static size_t cursor;
|
||||
static struct item *items = NULL;
|
||||
|
@ -73,8 +73,8 @@ static Colormap cmap;
|
|||
#include "config.h"
|
||||
|
||||
static char * cistrstr(const char *s, const char *sub);
|
||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||
static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp;
|
||||
static char *(*fstrstr)(const char *, const char *) = cistrstr;
|
||||
static void xinitvisual();
|
||||
|
||||
static unsigned int
|
||||
|
@ -133,7 +133,7 @@ cleanup(void)
|
|||
for (i = 0; i < SchemeLast; i++)
|
||||
free(scheme[i]);
|
||||
for (i = 0; items && items[i].text; ++i)
|
||||
free(items[i].text);
|
||||
free(revtab ? items[i].otext : items[i].text);
|
||||
free(items);
|
||||
drw_free(drw);
|
||||
XSync(dpy, False);
|
||||
|
@ -182,7 +182,7 @@ drawhighlights(struct item *item, int x, int y, int maxw)
|
|||
if (indentx - (lrpad / 2) - 1 < maxw)
|
||||
drw_text(
|
||||
drw,
|
||||
x + indentx - (lrpad / 2) - 1,
|
||||
x + indentx - (lrpad / 2), // there was a -1 here idk why
|
||||
y,
|
||||
MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||
bh, 0, highlight, 0
|
||||
|
@ -205,7 +205,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->stext, 0);
|
||||
int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||
drawhighlights(item, x, y, w);
|
||||
return r;
|
||||
}
|
||||
|
@ -266,15 +266,15 @@ drawmenu(void)
|
|||
}
|
||||
x += w;
|
||||
for (item = curr; item != next; item = item->right)
|
||||
x = drawitem(item, x, 0, textw_clamp(item->stext, mw - x - TEXTW(">") - TEXTW(numbers)));
|
||||
x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">") - TEXTW(numbers)));
|
||||
if (next) {
|
||||
w = TEXTW(">");
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0);
|
||||
drw_text(drw, mw - w - TEXTW(numbers) - border_width * 2, 0, w, bh, lrpad / 2, ">", 0);
|
||||
}
|
||||
}
|
||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||
drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
|
||||
drw_text(drw, mw - TEXTW(numbers) - border_width * 2, 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
|
||||
drw_map(drw, win, 0, 0, mw, mh);
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ insert:
|
|||
break;
|
||||
case XK_Return:
|
||||
case XK_KP_Enter:
|
||||
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
|
||||
puts((sel && !(ev->state & ShiftMask)) ? sel->otext : text);
|
||||
if (!(ev->state & ControlMask)) {
|
||||
cleanup();
|
||||
exit(0);
|
||||
|
@ -641,7 +641,6 @@ static void
|
|||
readstdin(void)
|
||||
{
|
||||
char *line = NULL;
|
||||
char *t = NULL;
|
||||
size_t i, junk, size = 0;
|
||||
ssize_t len;
|
||||
|
||||
|
@ -652,16 +651,15 @@ readstdin(void)
|
|||
die("cannot realloc %zu bytes:", size);
|
||||
if (line[len - 1] == '\n')
|
||||
line[len - 1] = '\0';
|
||||
items[i].text = line;
|
||||
if (t = strchr(buf, '\t'))
|
||||
*t = '\0';
|
||||
items[i].stext = line;
|
||||
// if (!(items[i].stext = strdup(buf)))
|
||||
// die("cannot strdup %zu bytes:", strlen(buf) + 1);
|
||||
items[i].text = items[i].otext = line;
|
||||
if ((line = strchr(line, '\t'))) {
|
||||
*line++ = '\0';
|
||||
revtab ? (items[i].text = line) : (items[i].otext = line);
|
||||
}
|
||||
items[i].out = 0;
|
||||
}
|
||||
if (items)
|
||||
items[i].text = NULL;
|
||||
items[i].text = items[i].otext = NULL;
|
||||
lines = MIN(lines, i);
|
||||
}
|
||||
|
||||
|
@ -769,13 +767,13 @@ setup(void)
|
|||
break;
|
||||
|
||||
if (centered) {
|
||||
mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
|
||||
mw = (dmw>0 ? dmw : 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 ? dmy : info[i].height - mh - dmy);
|
||||
mw = (dmw>0 ? dmw : info[o].width);
|
||||
mw = (dmw>0 ? dmw : info[i].width);
|
||||
}
|
||||
|
||||
XFree(info);
|
||||
|
@ -787,7 +785,7 @@ setup(void)
|
|||
parentwin);
|
||||
|
||||
if (centered) {
|
||||
mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
|
||||
mw = (dmw>0 ? dmw : MIN(MAX(max_textw() + promptw, min_width), wa.width));
|
||||
x = (wa.width - mw) / 2;
|
||||
y = (wa.height - mh) / 2;
|
||||
} else {
|
||||
|
@ -796,7 +794,6 @@ setup(void)
|
|||
mw = (dmw>0 ? dmw : wa.width);
|
||||
}
|
||||
}
|
||||
// inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||
inputw = MIN(inputw, mw/3);
|
||||
match();
|
||||
|
||||
|
@ -838,8 +835,8 @@ setup(void)
|
|||
static void
|
||||
usage(void)
|
||||
{
|
||||
fputs("usage: dmenu [-bfsvS] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
|
||||
" [-x xoffset] [-y yoffset] [-z width]\n"
|
||||
fputs("usage: dmenu [-bfsvScr] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
|
||||
" [-x xoffset] [-y yoffset] [-z width] [-bw bwidth]\n"
|
||||
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid] [-n number]\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -859,20 +856,16 @@ main(int argc, char *argv[])
|
|||
topbar = 0;
|
||||
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||
fast = 1;
|
||||
<<<<<<< ours
|
||||
else if (!strcmp(argv[i], "-S")) /* do not sort matches */
|
||||
sortmatches = false;
|
||||
else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */
|
||||
fstrncmp = strncmp;
|
||||
fstrstr = strstr;
|
||||
=======
|
||||
else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||
} else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||
centered = 1;
|
||||
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||
fstrncmp = strncasecmp;
|
||||
fstrstr = cistrstr;
|
||||
>>>>>>> theirs
|
||||
} else if (i + 1 == argc)
|
||||
else if (!strcmp(argv[i], "-r")) /* reverse the tab separation */
|
||||
revtab = (!revtab);
|
||||
else if (i + 1 == argc)
|
||||
usage();
|
||||
/* these options take one argument */
|
||||
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||
|
|
14
dmenu_run
14
dmenu_run
|
@ -1,2 +1,14 @@
|
|||
#!/bin/sh
|
||||
dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
|
||||
set -efu
|
||||
|
||||
# dmenu_run improved
|
||||
# command ending with '!', is started in the terminal.
|
||||
|
||||
test -s "$HOME"/.dmenurc && . "$HOME"/.dmenurc
|
||||
|
||||
cmd="$(dmenu_path | dmenu "$@")"
|
||||
|
||||
case "$cmd" in
|
||||
*\!) "${TERMINAL:-urxvt}" -e "${cmd%?}" & ;;
|
||||
*) "${cmd}" & ;;
|
||||
esac
|
||||
|
|
Loading…
Reference in New Issue