[wiki] [sites] rewrite of cool_autostart patch || bit9tream

From: <git_AT_suckless.org>
Date: Sat, 30 May 2020 18:04:34 +0200

commit 3e1fc37e9e5a445db0a8fec122863dab8d941132
Author: bit9tream <bit6tream_AT_cock.li>
Date: Sat May 30 19:00:34 2020 +0300

    rewrite of cool_autostart patch
    
    now it is easier for user to add elements to an `autostart` array

diff --git a/dwm.suckless.org/patches/cool_autostart/dwm-cool-autostart-6.2.diff b/dwm.suckless.org/patches/cool_autostart/dwm-cool-autostart-6.2.diff
index be8b92e5..049fab03 100644
--- a/dwm.suckless.org/patches/cool_autostart/dwm-cool-autostart-6.2.diff
+++ b/dwm.suckless.org/patches/cool_autostart/dwm-cool-autostart-6.2.diff
_AT_@ -1,20 +1,20 @@
 diff --git a/config.def.h b/config.def.h
-index 1c0b587..83f5275 100644
+index 1c0b587..ca33338 100644
 --- a/config.def.h
 +++ b/config.def.h
 _AT_@ -18,6 +18,10 @@ static const char *colors[][3] = {
          [SchemeSel] = { col_gray4, col_cyan, col_cyan },
  };
  
-+static char* const autostart[][2] = { /* please replace 2 with maximum number of arguments from autostart array */
-+ { "st", NULL },
++static void const *autostart[] = { /* please replace 2 with maximum number of arguments from autostart array */
++ &(const char *[]){ "st", NULL },
 +};
 +
  /* tagging */
  static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
  
 diff --git a/dwm.c b/dwm.c
-index 4465af1..d65cf57 100644
+index 4465af1..5d54149 100644
 --- a/dwm.c
 +++ b/dwm.c
 _AT_@ -233,6 +233,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
_AT_@ -36,14 +36,14 @@ index 4465af1..d65cf57 100644
 +/* execute command from autostart array */
 +static void
 +autostart_exec() {
-+ autostart_pids = malloc((autostart_len + 1) * sizeof(pid_t));
-+ for (int i = 0;i < autostart_len;i++) {
-+ autostart_pids[i] = fork();
-+ if (autostart_pids[i] == 0) {
-+ setsid();
-+ execvp(autostart[i][0], autostart[i]);
-+ }
-+ }
++ autostart_pids = malloc((LENGTH(autostart) + 1) * sizeof(pid_t));
++ for (int i = 0;i < LENGTH(autostart);i++) {
++ autostart_pids[i] = fork();
++ if (autostart_pids[i] == 0) {
++ setsid();
++ execvp(((char **)(autostart[i]))[0], autostart[i]);
++ }
++ }
 +}
 +
  /* function implementations */
_AT_@ -53,11 +53,11 @@ index 4465af1..d65cf57 100644
  void
  quit(const Arg *arg)
  {
-+ /* kill child processes */
-+ for (int i = 0;i < autostart_len;i++) {
-+ kill(autostart_pids[i], SIGTERM);
-+ waitpid(autostart_pids[i], NULL, 0);
-+ }
++ /* kill child processes */
++ for (int i = 0;i < autostart_len;i++) {
++ kill(autostart_pids[i], SIGTERM);
++ waitpid(autostart_pids[i], NULL, 0);
++ }
          running = 0;
  }
  
_AT_@ -65,7 +65,7 @@ index 4465af1..d65cf57 100644
          if (!(dpy = XOpenDisplay(NULL)))
                  die("dwm: cannot open display");
          checkotherwm();
-+ autostart_exec();
++ 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 b32c3c64..a9f274d6 100644
--- a/dwm.suckless.org/patches/cool_autostart/index.md
+++ b/dwm.suckless.org/patches/cool_autostart/index.md
_AT_@ -9,13 +9,13 @@ And when you exit dwm all processes from `autostart` array will be killed.
 Example
 -------
 
- static char* const autostart[][4] = {
- { "mpd-notification", NULL },
- { "hsetroot", "-center", "/usr/home/bit6tream/pic/wallapper.png", NULL },
- { "xrdb", "/usr/home/bit6tream/.config/X/Xresources", NULL },
- { "sh", "-c", "while :; do dwmstatus.sh -; sleep 60; done", NULL },
- { "dunst", NULL },
- { "picom", NULL }
+ static char* const autostart[] = {
+ &(const char *[]){ "mpd-notification", NULL },
+ &(const char *[]){ "hsetroot", "-center", "/usr/home/bit6tream/pic/wallapper.png", NULL },
+ &(const char *[]){ "xrdb", "/usr/home/bit6tream/.config/X/Xresources", NULL },
+ &(const char *[]){ "sh", "-c", "while :; do dwmstatus.sh -; sleep 60; done", NULL },
+ &(const char *[]){ "dunst", NULL },
+ &(const char *[]){ "picom", NULL }
         };
 
 Attention
Received on Sat May 30 2020 - 18:04:34 CEST

This archive was generated by hypermail 2.3.0 : Sat May 30 2020 - 18:12:45 CEST