Re: [dev] [dwm][PATCH] Add function to exec into another executable

2023-07-15 Thread Dmitry Bogatov
On Sat, Jul 15, 2023 at 08:48:29PM +0600, NRK wrote:
> Hi Dmitry,
> 
> >  but I don't need to restart X, which is much more annoying.
> 
> There's no need to patch anything to achieve this. You can do something
> like this in your xinitrc:
> 
>   while :; do dwm; done
> 
> This will re-run dwm after it quits. And if you want to quit for real,
> then you can just invoke `shutdown`.

Or exec into runsv(8). You are right, thank you for the nice idea.
Nevermind the patch.



Re: [dev] [dwm][PATCH] Add function to exec into another executable

2023-07-15 Thread NRK
Hi Dmitry,

>  but I don't need to restart X, which is much more annoying.

There's no need to patch anything to achieve this. You can do something
like this in your xinitrc:

while :; do dwm; done

This will re-run dwm after it quits. And if you want to quit for real,
then you can just invoke `shutdown`.

- NRK



[dev] [dwm][PATCH] Add function to exec into another executable

2023-07-15 Thread Dmitry Bogatov
Hello.

I want to share my patch that I have been using for couple months that
simplifies reconfiguring of the dwm. It adds function to execute into
another executable, be it another build of dwm or another window manager.

I have following lines in `dwm.h':

static const char *dwmcmd[] = {"dwm", NULL };
static const Key keys[] = {
<...snip...>
{MODKEY | ShiftMask, XK_r, exec, {.v = dwmcmd}},
<...snip...>

Exec'ing loses manual window arrangement (window arrangement gets reset
to one according to `rules', but I don't need to restart X, which is
much more annoying.

I think usefulness/complexity ratio is good enough to include this patch
into dwm main release.
>From fa5f13e0c2e17de070968c335f47f5b123f39261 Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov 
Date: Wed, 22 Feb 2023 17:02:48 -0500
Subject: [PATCH] dwm: add support of execing into another window manager

---
 dwm.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/dwm.c b/dwm.c
index 253aba7..1cd3396 100644
--- a/dwm.c
+++ b/dwm.c
@@ -207,6 +207,7 @@ static void seturgent(Client *c, int urg);
 static void showhide(Client *c);
 static void sigchld(int unused);
 static void spawn(const Arg *arg);
+static void exec(const Arg *arg);
 static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static void tile(Monitor *m);
@@ -1636,6 +1637,12 @@ sigchld(int unused)
while (0 < waitpid(-1, NULL, WNOHANG));
 }
 
+void
+exec(const Arg *arg)
+{
+   execvp(((char **)arg->v)[0], (char **)arg->v);
+}
+
 void
 spawn(const Arg *arg)
 {
-- 
If possible, please keep mailing list in CC. It is public.