dwl

My patch set and modifications to dwl
git clone git://git.ethandl.dev/dwl
Log | Files | Refs | README | LICENSE

commit b75d24f9760b6946a9ce4387d608eec71e450307
parent b36d0144679df32c0e7f9824462f178bf0d7a193
Author: Ethan Long <Ethan.Long@anu.edu.au>
Date:   Sun, 29 Dec 2024 23:51:30 +1100

Removed the autostart patch, it's not needed!

Just use the -s option!

Diffstat:
Mconfig.def.h | 7-------
Mconfig.h | 11-----------
Mdwl.c | 59+++++------------------------------------------------------
Dpatches/autostart-0.7.patch | 154-------------------------------------------------------------------------------
4 files changed, 5 insertions(+), 226 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -32,13 +32,6 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; /* logging */ static int log_level = WLR_ERROR; -/* Autostart */ -static const char *const autostart[] = { - "wbg", "/path/to/your/image", NULL, - NULL /* terminate */ -}; - - /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ static const Rule rules[] = { /* app_id title tags mask isfloating monitor */ diff --git a/config.h b/config.h @@ -41,17 +41,6 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; /* logging */ static int log_level = WLR_ERROR; -/* Autostart */ -static const char *const autostart[] = { - //"wbg", "/path/to/your/image", NULL, - "pipewire", NULL, - "pipewire-pulse", NULL, - "wireplumber", NULL, - "swww-daemon", NULL, - "swww_default_bg", NULL, - NULL /* terminate */ -}; - /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ static const Rule rules[] = { diff --git a/dwl.c b/dwl.c @@ -277,7 +277,6 @@ static void arrange(Monitor *m); static void arrangelayer(Monitor *m, struct wl_list *list, struct wlr_box *usable_area, int exclusive); static void arrangelayers(Monitor *m); -static void autostartexec(void); static void axisnotify(struct wl_listener *listener, void *data); static bool baracceptsinput(struct wlr_scene_buffer *buffer, double *sx, double *sy); static void bufdestroy(struct wlr_buffer *buffer); @@ -493,9 +492,6 @@ static xcb_atom_t netatom[NetLast]; /* attempt to encapsulate suck into one file */ #include "client.h" -static pid_t *autostart_pids; -static size_t autostart_len; - /* function implementations */ void applybounds(Client *c, struct wlr_box *bbox) @@ -650,27 +646,6 @@ arrangelayers(Monitor *m) } void -autostartexec(void) { - const char *const *p; - size_t i = 0; - - /* count entries */ - for (p = autostart; *p; autostart_len++, p++) - while (*++p); - - autostart_pids = calloc(autostart_len, sizeof(pid_t)); - for (p = autostart; *p; i++, p++) { - if ((autostart_pids[i] = fork()) == 0) { - setsid(); - execvp(*p, (char *const *)p); - die("dwl: execvp %s:", *p); - } - /* skip arguments */ - while (*++p); - } -} - -void axisnotify(struct wl_listener *listener, void *data) { /* This event is forwarded by the cursor when a pointer emits an axis event, @@ -868,21 +843,11 @@ checkidleinhibitor(struct wlr_surface *exclude) void cleanup(void) { - size_t i; #ifdef XWAYLAND wlr_xwayland_destroy(xwayland); xwayland = NULL; #endif wl_display_destroy_clients(dpy); - - /* 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); - } - } - if (child_pid > 0) { kill(-child_pid, SIGTERM); waitpid(child_pid, NULL, 0); @@ -1801,31 +1766,18 @@ void handlesig(int signo) { if (signo == SIGCHLD) { +#ifdef XWAYLAND siginfo_t in; /* wlroots expects to reap the XWayland process itself, so we * use WNOWAIT to keep the child waitable until we know it's not * XWayland. */ while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid -#ifdef XWAYLAND - && (!xwayland || in.si_pid != xwayland->server->pid) -#endif - ) { - pid_t *p, *lim; + && (!xwayland || in.si_pid != xwayland->server->pid)) waitpid(in.si_pid, NULL, 0); - if (in.si_pid == child_pid) - child_pid = -1; - if (!(p = autostart_pids)) - continue; - lim = &p[autostart_len]; - - for (; p < lim; p++) { - if (*p == in.si_pid) { - *p = -1; - break; - } - } - } +#else + while (waitpid(-1, NULL, WNOHANG) > 0); +#endif } else if (signo == SIGINT || signo == SIGTERM) { quit(NULL); } @@ -2582,7 +2534,6 @@ run(char *startup_cmd) die("startup: backend_start"); /* Now that the socket exists and the backend is started, run the startup command */ - autostartexec(); if (startup_cmd) { if ((child_pid = fork()) < 0) die("startup: fork:"); diff --git a/patches/autostart-0.7.patch b/patches/autostart-0.7.patch @@ -1,154 +0,0 @@ -From 787f7252d63945996f009828aff3c44afd0f7781 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= - <leohdz172@proton.me> -Date: Sat, 8 Jul 2023 17:11:36 -0600 -Subject: [PATCH] port autostart patch from dwm -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -https://dwm.suckless.org/patches/cool_autostart/ -Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me> ---- - config.def.h | 7 +++++++ - dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++----- - 2 files changed, 61 insertions(+), 5 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 22d2171..8dc6502 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -20,6 +20,13 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca - /* logging */ - static int log_level = WLR_ERROR; - -+/* Autostart */ -+static const char *const autostart[] = { -+ "wbg", "/path/to/your/image", NULL, -+ NULL /* terminate */ -+}; -+ -+ - /* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */ - static const Rule rules[] = { - /* app_id title tags mask isfloating monitor */ -diff --git a/dwl.c b/dwl.c -index 5bf995e..e8b8727 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -249,6 +249,7 @@ static void arrange(Monitor *m); - static void arrangelayer(Monitor *m, struct wl_list *list, - struct wlr_box *usable_area, int exclusive); - static void arrangelayers(Monitor *m); -+static void autostartexec(void); - static void axisnotify(struct wl_listener *listener, void *data); - static void buttonpress(struct wl_listener *listener, void *data); - static void chvt(const Arg *arg); -@@ -432,6 +433,9 @@ static xcb_atom_t netatom[NetLast]; - /* attempt to encapsulate suck into one file */ - #include "client.h" - -+static pid_t *autostart_pids; -+static size_t autostart_len; -+ - /* function implementations */ - void - applybounds(Client *c, struct wlr_box *bbox) -@@ -580,6 +584,27 @@ arrangelayers(Monitor *m) - } - } - -+void -+autostartexec(void) { -+ const char *const *p; -+ size_t i = 0; -+ -+ /* count entries */ -+ for (p = autostart; *p; autostart_len++, p++) -+ while (*++p); -+ -+ autostart_pids = calloc(autostart_len, sizeof(pid_t)); -+ for (p = autostart; *p; i++, p++) { -+ if ((autostart_pids[i] = fork()) == 0) { -+ setsid(); -+ execvp(*p, (char *const *)p); -+ die("dwl: execvp %s:", *p); -+ } -+ /* skip arguments */ -+ while (*++p); -+ } -+} -+ - void - axisnotify(struct wl_listener *listener, void *data) - { -@@ -676,11 +701,21 @@ checkidleinhibitor(struct wlr_surface *exclude) - void - cleanup(void) - { -+ size_t i; - #ifdef XWAYLAND - wlr_xwayland_destroy(xwayland); - xwayland = NULL; - #endif - wl_display_destroy_clients(dpy); -+ -+ /* 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); -+ } -+ } -+ - if (child_pid > 0) { - kill(-child_pid, SIGTERM); - waitpid(child_pid, NULL, 0); -@@ -1497,18 +1532,31 @@ void - handlesig(int signo) - { - if (signo == SIGCHLD) { --#ifdef XWAYLAND - siginfo_t in; - /* wlroots expects to reap the XWayland process itself, so we - * use WNOWAIT to keep the child waitable until we know it's not - * XWayland. - */ - while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid -- && (!xwayland || in.si_pid != xwayland->server->pid)) -- waitpid(in.si_pid, NULL, 0); --#else -- while (waitpid(-1, NULL, WNOHANG) > 0); -+#ifdef XWAYLAND -+ && (!xwayland || in.si_pid != xwayland->server->pid) - #endif -+ ) { -+ pid_t *p, *lim; -+ waitpid(in.si_pid, NULL, 0); -+ if (in.si_pid == child_pid) -+ child_pid = -1; -+ if (!(p = autostart_pids)) -+ continue; -+ lim = &p[autostart_len]; -+ -+ for (; p < lim; p++) { -+ if (*p == in.si_pid) { -+ *p = -1; -+ break; -+ } -+ } -+ } - } else if (signo == SIGINT || signo == SIGTERM) { - quit(NULL); - } -@@ -2224,6 +2272,7 @@ run(char *startup_cmd) - die("startup: backend_start"); - - /* Now that the socket exists and the backend is started, run the startup command */ -+ autostartexec(); - if (startup_cmd) { - int piperw[2]; - if (pipe(piperw) < 0) --- -2.45.2 -