[dev] [dwm] execwm(), ie, self?

From: Steffen Nurpmeso <steffen_AT_sdaoden.eu>
Date: Sat, 07 Sep 2024 03:46:32 +0200

Hello,

i am in the process of switching to dwm+dmenu after many years of
cwm, it is hard, thank you, because of sxmo that i am looking
forward for, some day.
What do you think of another accessible function, like (draft)

diff --git a/dwm.c b/dwm.c
index 67c6b2bc6d..ca21a89098 100644
--- a/dwm.c
+++ b/dwm.c
_AT_@ -141,6 +141,8 @@ typedef struct {
         int monitor;
 } Rule;
 
+static char **xargv;
+
 /* function declarations */
 static void applyrules(Client *c);
 static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
_AT_@ -206,6 +208,7 @@ static void setup(void);
 static void seturgent(Client *c, int urg);
 static void showhide(Client *c);
 static void spawn(const Arg *arg);
+static void execwm(const Arg *arg);
 static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static void tile(Monitor *m);
_AT_@ -1666,6 +1669,16 @@ spawn(const Arg *arg)
         }
 }
 
+void
+execwm(const Arg *arg)
+{
+ setsid();
+ execvp(((char **)arg->v)[0], (char **)arg->v);
+ fprintf(stderr, "dwm: execvp wm '%s' failed:", ((char **)arg->v)[0]);
+ execvp(xargv[0], xargv);
+ die("dwm: re-exec failed:");
+}
+
 void
 tag(const Arg *arg)
 {
_AT_@ -2143,6 +2156,7 @@ zoom(const Arg *arg)
 int
 main(int argc, char *argv[])
 {
+ xargv = argv;
         if (argc == 2 && !strcmp("-v", argv[1]))
                 die("dwm-"VERSION);
         else if (argc != 1)

--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
Received on Sat Sep 07 2024 - 03:46:32 CEST

This archive was generated by hypermail 2.3.0 : Sat Sep 07 2024 - 03:48:09 CEST