dmenu_term.patch:
Patch that adds a command line-only option to make dmenu_run spawn the
command in a new terminal window. Useful for curses based interfaces or
other interactive command line applications.
dwm_dmenu_term.patch:
Adds a dwm keybind for the new dmenu option.
diff --git a/dmenu.1 b/dmenu.1
index bbee17d..f5ee529 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -22,6 +22,8 @@ dmenu \- dynamic menu
 .IR color ]
 .RB [ \-sf
 .IR color ]
+.RB [ \-term
+.IR command ]
 .RB [ \-v ]
 .P
 .BR dmenu_run " ..."
diff --git a/dmenu.c b/dmenu.c
index 8d9bbb6..d20697b 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -55,6 +55,7 @@ static Item *prev, *curr, *next, *sel;
 static Window win;
 static XIC xic;
 static int mon = -1;
+static const char *term = NULL;
 
 #include "config.h"
 
@@ -99,6 +100,8 @@ main(int argc, char *argv[]) {
 			selbgcolor = argv[++i];
 		else if(!strcmp(argv[i], "-sf"))  /* selected foreground color */
 			selfgcolor = argv[++i];
+		else if(!strcmp(argv[i], "-term"))
+			term = argv[++i];
 		else
 			usage();
 
@@ -367,6 +370,8 @@ keypress(XKeyEvent *ev) {
 		break;
 	case XK_Return:
 	case XK_KP_Enter:
+		if(term)
+			printf("%s -e ", term);
 		puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
 		if(!(ev->state & ControlMask))
 			exit(EXIT_SUCCESS);
diff --git a/config.def.h b/config.def.h
index 875885b..e1a9483 100644
--- a/config.def.h
+++ b/config.def.h
@@ -51,12 +51,15 @@ static const Layout layouts[] = {
 
 /* commands */
 static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
+static const char terminal[] = "st";
 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
-static const char *termcmd[]  = { "st", NULL };
+static const char *sdmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, "-term", terminal, NULL };
+static const char *termcmd[]  = { terminal, NULL };
 
 static Key keys[] = {
 	/* modifier                     key        function        argument */
 	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
+	{ MODKEY|ShiftMask,             XK_p,      spawn,          {.v = sdmenucmd } },
 	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
 	{ MODKEY,                       XK_b,      togglebar,      {0} },
 	{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },

Reply via email to