@@ -54,6 +54,7 @@ Menu b2menu =
5454char 	* b3items [B3FIXED + MAXHIDDEN + 1 ] = 
5555{
5656	"New" ,
57+ 	"Launch" ,
5758	"Reshape" ,
5859	"Move" ,
5960	"Delete" ,
@@ -64,6 +65,7 @@ char	*b3items[B3FIXED+MAXHIDDEN+1] =
6465enum 
6566{
6667	New ,
68+ 	Launch ,
6769	Reshape ,
6870	Move ,
6971	Delete ,
@@ -80,6 +82,34 @@ Menu	egg =
8082	version 
8183};
8284
85+ void 
86+ runterm () {
87+ 	if (termprog  !=  NULL ){
88+ 		execl (shell , shell , "-c" , termprog , (char * )0 );
89+ 		fprintf (stderr , "rio: exec %s" , shell );
90+ 		perror (" failed" );
91+ 	}
92+ 	execlp ("9term" , "9term" , scrolling  ? "-ws"  : "-w" , (char * )0 );
93+ 	execlp ("xterm" , "xterm" , "-ut" , (char * )0 );
94+ 	perror ("rio: exec 9term/xterm failed" );
95+ 	exit (1 );
96+ }
97+ 
98+ void 
99+ runlauncher () {
100+ 	if (launcher  !=  NULL ) {
101+ 		/* launcher parameters uses configured shell syntax */ 
102+ 		execl (shell , shell , "-c" , launcher , (char * )0 );
103+ 		perror ("rio: launcher failed" );
104+ 
105+ 		/* will try default launcher */ 
106+ 	}
107+ 
108+ 	execlp ("dmenu_run" , "dmenu_run" , (char * )0 );	
109+ 	perror ("rio: exec dmenu_run failed" );
110+ 	exit (1 );
111+ }
112+ 
83113void 
84114button (XButtonEvent  * e )
85115{
@@ -157,7 +187,10 @@ button(XButtonEvent *e)
157187		cmapnofocus (s );
158188	switch  (n  =  menuhit (e , & b3menu )){
159189	case  New :
160- 		spawn (s );
190+ 		spawn (s , runterm );
191+ 		break ;
192+ 	case  Launch :
193+ 		spawn (s , runlauncher );
161194		break ;
162195	case  Reshape :
163196		reshape (selectwin (1 , 0 , s ), Button3 , sweep , 0 );
@@ -184,7 +217,7 @@ button(XButtonEvent *e)
184217}
185218
186219void 
187- spawn (ScreenInfo  * s )
220+ spawn (ScreenInfo  * s ,  void  ( * fn )() )
188221{
189222	/* 
190223	 * ugly dance to cause sweeping for terminals. 
@@ -205,15 +238,9 @@ spawn(ScreenInfo *s)
205238			signal (SIGINT , SIG_DFL );
206239			signal (SIGTERM , SIG_DFL );
207240			signal (SIGHUP , SIG_DFL );
208- 			if (termprog  !=  NULL ){
209- 				execl (shell , shell , "-c" , termprog , (char * )0 );
210- 				fprintf (stderr , "rio: exec %s" , shell );
211- 				perror (" failed" );
212- 			}
213- 			execlp ("9term" , "9term" , scrolling  ? "-ws"  : "-w" , (char * )0 );
214- 			execlp ("xterm" , "xterm" , "-ut" , (char * )0 );
215- 			perror ("rio: exec 9term/xterm failed" );
216- 			exit (1 );
241+ 
242+ 			// run in child process 
243+ 			fn ();
217244		}
218245		exit (0 );
219246	}
0 commit comments