diff --git a/config.def.h b/config.def.h index dcffd38..8c18a07 100644 --- a/config.def.h +++ b/config.def.h @@ -20,4 +20,5 @@ static unsigned int lines = 0; * Characters not considered part of a word while deleting words * for example: " /?\"&[]" */ +static const char startpipe[] = "#"; static const char worddelimiters[] = " "; diff --git a/dmenu.c b/dmenu.c index e0c2f80..9ed07bc 100644 --- a/dmenu.c +++ b/dmenu.c @@ -35,6 +35,7 @@ struct item { }; static char text[BUFSIZ] = ""; +static char pipeout[8] = " | dmenu"; static int bh, mw, mh; static int sw, sh; /* X display screen geometry width, height */ static int inputw, promptw; @@ -416,7 +417,20 @@ keypress(XKeyEvent *ev) break; case XK_Return: case XK_KP_Enter: - puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); + if ((sel && !(ev->state & ShiftMask))) { + if (sel->text[0] == startpipe[0]) { + strncpy(sel->text + strlen(sel->text),pipeout,8); + puts(sel->text+1); + } + puts(sel->text); + } + else { + if (text[0] == startpipe[0]) { + strncpy(text + strlen(text),pipeout,8); + puts(text+1); + } + puts(text); + } if (!(ev->state & ControlMask)) { cleanup(); exit(0);