[dwm] xterm -e [dmenu]

From: bill lam <cbill.lam_AT_gmail.com>
Date: Wed, 10 Sep 2008 23:06:57 +0800

Hi All,
I want to exec some console program, so instead of exec directly the
output from dmenu, I change it to something like,
   xterm -e "outuot from dmenu"
I modified config.h and dwm.c as follows. However I noticed that it
spawn a xterm before dmenu has started. Is there any way to suppress
xterm before dmenu get finished? Any comments to improve the code
are welcome. Or if anyone has already written such patch, I would like
to copy. :-)

/*** config.hc ***/
static Key keys[] = {
        /* modifier key function argument */
        { MODKEY|ShiftMask, XK_p, termspawn, {.v = dmenucmd } },

/*** dwm.c ***/

static void termspawn(const Arg *arg);

void
termspawn(const Arg *arg) {
        /* The double-fork construct avoids zombie processes and keeps the code
         * clean from stupid signal handlers. */
  char *argv[3]; /* the command line argument */
  argv[0] = (char*)termcmd[0];
  argv[1] = "-e";
  argv[2] = ((char **)arg->v)[0];
        if(fork() == 0) {
                if(fork() == 0) {
                        if(dpy)
                                close(ConnectionNumber(dpy));
                        setsid();
                        execvp(*argv, argv);
                        fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
                        perror(" failed");
                }
                exit(0);
        }
        wait(0);
}

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
Received on Wed Sep 10 2008 - 15:06:57 UTC

This archive was generated by hypermail 2.2.0 : Wed Sep 10 2008 - 15:12:03 UTC