[hackers] Re: [dwm][PATCH] Proper restart function

From: Tolu2 <toluschr_AT_protonmail.com>
Date: Mon, 08 Mar 2021 11:29:12 +0000

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
> _AT_@ -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";
> _AT_@ -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"
> _AT_@ -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.
Received on Mon Mar 08 2021 - 12:29:12 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 08 2021 - 12:36:34 CET