On Saturday, March 6, 2021 4:59 PM toluschr wrote: > The currently available patch reads /proc/self/exe, which fails when > recompiling (Why else would I want to restart dwm?) > This patch simply saves the commandline arguments on startup and re-executes > them. > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ > > dwm.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/dwm.c b/dwm.c > index 664c527..9e8160f 100644 > --- a/dwm.c > +++ b/dwm.c > @@ -234,6 +234,7 @@ static int xerror(Display *dpy, XErrorEvent *ee); > static int xerrordummy(Display *dpy, XErrorEvent *ee); > static int xerrorstart(Display *dpy, XErrorEvent *ee); > static void zoom(const Arg *arg); > +static void restart(const Arg arg); > / variables */static const char broken[] = "broken"; > @@ -268,6 +269,7 @@ static Display *dpy; > static Drw *drw; > static Monitor *mons, *selmon; > static Window root, wmcheckwin; > +static char *argv; > / configuration, allows nested code to access above variables */#include > "config.h" > @@ -2127,9 +2129,17 @@ zoom(const Arg *arg) > pop(c); > } > > +void > +restart(const Arg *arg) > +{ > > - execvp(argv[0], argv); > +} > > - > > int > -main(int argc, char *argv[]) > +main(int argc, char *_argv[]) > { > > - argv = _argv; > - if (argc == 2 && !strcmp("-v", argv[1])) > die("dwm-"VERSION); > else if (argc != 1) > -- > 2.30.1 >
I noticed that it might not have been clear that my intention was to have this included in the mainline. Since there is a quit function, why not also have a restart? It makes edits to the source code much more pleasant.