diff --git a/config.h b/config.h index 2c34d97..1b6ad5d 100644 --- a/config.h +++ b/config.h @@ -176,11 +176,3 @@ static const Button buttons[] = { { MODKEY, BTN_MIDDLE, togglefloating, {0} }, { MODKEY, BTN_RIGHT, moveresize, {.ui = CurResize} }, }; - -static const char *const autostart[] = { - "wbg", "/home/fabric/Pictures/wallpaper/wallpaper.jpg", NULL, - "wlsunset", "-l", "43.7", "-L", "-79.4", NULL, - "fcitx5", NULL, - "wlr-randr", "--output", "DP-5", "--mode", "3440x1440@144Hz", NULL, - NULL -}; diff --git a/flake.nix b/flake.nix index 2d9e4ad..b44030b 100644 --- a/flake.nix +++ b/flake.nix @@ -44,8 +44,6 @@ xorg.xcbutilwm # ✅ for xcb_ewmh.h ]; - patches = [./patches/autostart.patch]; - # The build and installation process buildPhase = '' make diff --git a/patches/autostart.patch b/patches/autostart.patch deleted file mode 100644 index 0e326ce..0000000 --- a/patches/autostart.patch +++ /dev/null @@ -1,147 +0,0 @@ -From 3b0b0249d900121a90528616f4d11f733c7a5ca2 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= - -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 ---- - config.def.h | 7 +++++++ - dwl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--- - 2 files changed, 62 insertions(+), 3 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 22d2171d..8dc6502c 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 ad21e1ba..3118e07f 100644 ---- a/dwl.c -+++ b/dwl.c -@@ -246,6 +246,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); -@@ -455,6 +456,9 @@ static struct wlr_xwayland *xwayland; - /* 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) -@@ -599,6 +603,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) - { -@@ -695,12 +720,23 @@ checkidleinhibitor(struct wlr_surface *exclude) - void - cleanup(void) - { -+ size_t i; -+ - cleanuplisteners(); - #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); -@@ -1551,10 +1587,25 @@ gpureset(struct wl_listener *listener, void *data) - void - handlesig(int signo) - { -- if (signo == SIGCHLD) -- while (waitpid(-1, NULL, WNOHANG) > 0); -- else if (signo == SIGINT || signo == SIGTERM) -+ if (signo == SIGCHLD) { -+ pid_t pid, *p, *lim; -+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) { -+ if (pid == child_pid) -+ child_pid = -1; -+ if (!(p = autostart_pids)) -+ continue; -+ lim = &p[autostart_len]; -+ -+ for (; p < lim; p++) { -+ if (*p == pid) { -+ *p = -1; -+ break; -+ } -+ } -+ } -+ } else if (signo == SIGINT || signo == SIGTERM) { - quit(NULL); -+ } - } - - void -@@ -2241,6 +2292,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.48.0