summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-08-10 10:22:21 +0200
committerbakkeby <[email protected]>2020-08-10 10:24:16 +0200
commitdfe1c405630ab912501d5bb841a3fc34738a515c (patch)
tree90e2a04b6ed3d8f414f3e11ab5ae2a6bc5f4d1bb /patch
parent85dd49a6a4fd5dfdbb9055ae27b996777cbe1f1f (diff)
downloaddwm-flexipatch-dfe1c405630ab912501d5bb841a3fc34738a515c.tar.gz
dwm-flexipatch-dfe1c405630ab912501d5bb841a3fc34738a515c.zip
Adding cool autostart patch
Diffstat (limited to 'patch')
-rw-r--r--patch/cool_autostart.c28
-rw-r--r--patch/cool_autostart.h1
-rw-r--r--patch/include.c3
-rw-r--r--patch/include.h3
4 files changed, 35 insertions, 0 deletions
diff --git a/patch/cool_autostart.c b/patch/cool_autostart.c
new file mode 100644
index 0000000..2bc3c3b
--- /dev/null
+++ b/patch/cool_autostart.c
@@ -0,0 +1,28 @@
+/* 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\n", *p);
+ perror(" failed");
+ _exit(EXIT_FAILURE);
+ }
+ /* skip arguments */
+ while (*++p);
+ }
+} \ No newline at end of file
diff --git a/patch/cool_autostart.h b/patch/cool_autostart.h
new file mode 100644
index 0000000..8dc0d19
--- /dev/null
+++ b/patch/cool_autostart.h
@@ -0,0 +1 @@
+static void autostart_exec(void); \ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index 9e008b9..aaaf123 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -76,6 +76,9 @@
#if CMDCUSTOMIZE_PATCH
#include "cmdcustomize.c"
#endif
+#if COOL_AUTOSTART_PATCH
+#include "cool_autostart.c"
+#endif
#if CYCLELAYOUTS_PATCH
#include "cyclelayouts.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 245933e..e879d80 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -73,6 +73,9 @@
#if CMDCUSTOMIZE_PATCH
#include "cmdcustomize.h"
#endif
+#if COOL_AUTOSTART_PATCH
+#include "cool_autostart.h"
+#endif
#if CYCLELAYOUTS_PATCH
#include "cyclelayouts.h"
#endif