[wiki] [sites] [dwm][patches][cool_autostart] Update for dwm 6.5 || LUSEDOU

From: <git_AT_suckless.org>
Date: Thu, 22 May 2025 17:50:45 +0200

commit 27e83c3b4eef48136b72c6a4ced5e628fef09706
Author: LUSEDOU <lusedou_AT_gmail.com>
Date: Thu May 22 10:50:03 2025 -0500

    [dwm][patches][cool_autostart] Update for dwm 6.5

diff --git a/dwm.suckless.org/patches/cool_autostart/dwm-cool_autostart-6.5.diff b/dwm.suckless.org/patches/cool_autostart/dwm-cool_autostart-6.5.diff
new file mode 100644
index 00000000..22b6ecd1
--- /dev/null
+++ b/dwm.suckless.org/patches/cool_autostart/dwm-cool_autostart-6.5.diff
_AT_@ -0,0 +1,121 @@
+diff --git a/config.def.h b/config.def.h
+index 9efa774..aba210d 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -18,6 +18,11 @@ static const char *colors[][3] = {
+ [SchemeSel] = { col_gray4, col_cyan, col_cyan },
+ };
+
++static const char *const autostart[] = {
++ "st", NULL,
++ NULL /* terminate */
++};
++
+ /* tagging */
+ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+
+diff --git a/dwm.c b/dwm.c
+index f1d86b2..3ce99fc 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -233,6 +233,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 autostart_exec(void);
+
+ /* variables */
+ static const char broken[] = "broken";
+_AT_@ -274,6 +275,36 @@ static Window root, wmcheckwin;
+ /* compile-time check if all tags fit into an unsigned int bit array. */
+ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
+
++/* dwm will keep pid's of processes from autostart array and kill them at quit */
++static pid_t *autostart_pids;
++static size_t autostart_len;
++
++/* execute command from autostart array */
++static void
++autostart_exec() {
++ const char *const *p;
++ size_t i = 0;
++
++ /* count entries */
++ for (p = autostart; *p; autostart_len++, p++)
++ while (*++p);
++
++ autostart_pids = malloc(autostart_len * sizeof(pid_t));
++ for (p = autostart; *p; i++, p++) {
++ if ((autostart_pids[i] = fork()) == 0) {
++ setsid();
++ execvp(*p, (char *const *)p);
++ fprintf(stderr, "dwm: execvp %s
", *p);
++ perror(" failed");
++ _exit(EXIT_FAILURE);
++ }
++ /* skip arguments */
++ while (*++p);
++ }
++}
++
++
++
+ /* function implementations */
+ void
+ applyrules(Client *c)
+_AT_@ -1258,6 +1289,16 @@ propertynotify(XEvent *e)
+ void
+ quit(const Arg *arg)
+ {
++ size_t i;
++
++ /* kill child processes */
++ for (i = 0; i < autostart_len; i++) {
++ if (0 < autostart_pids[i]) {
++ kill(autostart_pids[i], SIGTERM);
++ waitpid(autostart_pids[i], NULL, 0);
++ }
++ }
++
+ running = 0;
+ }
+
+_AT_@ -1543,6 +1584,7 @@ setup(void)
+ XSetWindowAttributes wa;
+ Atom utf8string;
+ struct sigaction sa;
++ pid_t pid;
+
+ /* do not transform children into zombies when they terminate */
+ sigemptyset(&sa.sa_mask);
+_AT_@ -1551,7 +1593,21 @@ setup(void)
+ sigaction(SIGCHLD, &sa, NULL);
+
+ /* clean up any zombies (inherited from .xinitrc etc) immediately */
+- while (waitpid(-1, NULL, WNOHANG) > 0);
++ while (0 < (pid = waitpid(-1, NULL, WNOHANG))) {
++ pid_t *p, *lim;
++
++ if (!(p = autostart_pids))
++ continue;
++ lim = &p[autostart_len];
++
++ for (; p < lim; p++) {
++ if (*p == pid) {
++ *p = -1;
++ break;
++ }
++ }
++
++ }
+
+ /* init screen */
+ screen = DefaultScreen(dpy);
+_AT_@ -2152,6 +2208,7 @@ main(int argc, char *argv[])
+ if (!(dpy = XOpenDisplay(NULL)))
+ die("dwm: cannot open display");
+ checkotherwm();
++ autostart_exec();
+ setup();
+ #ifdef __OpenBSD__
+ if (pledge("stdio rpath proc exec", NULL) == -1)
diff --git a/dwm.suckless.org/patches/cool_autostart/index.md b/dwm.suckless.org/patches/cool_autostart/index.md
index e3d6a72e..ab85ddc4 100644
--- a/dwm.suckless.org/patches/cool_autostart/index.md
+++ b/dwm.suckless.org/patches/cool_autostart/index.md
_AT_@ -29,9 +29,11 @@ Download
 --------
 * [dwm-cool-autostart-6.2.diff](dwm-cool-autostart-6.2.diff)
 * [dwm-cool-autostart-20240312-9f88553.diff](dwm-cool-autostart-20240312-9f88553.diff)
+* [dwm-cool_autostart-6.5.diff](dwm-cool_autostart-6.5.diff)
 
 Authors
 -------
 * bit6tream <bit6tream_AT_cock.li> [bit6tream's gitlab](https://gitlab.com/bit9tream)
 * zsugabubus <zsugabubus_AT_national.shitposting.agency>
 * Son Phan Trung <phantrungson17_AT_gmail.com>
+* Luis Dolorier <lusedou_AT_gmail.com>
Received on Thu May 22 2025 - 17:50:45 CEST

This archive was generated by hypermail 2.3.0 : Thu May 22 2025 - 18:00:53 CEST