sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 3e1fc37e9e5a445db0a8fec122863dab8d941132
parent 7a2f9fe930c2e364e6268ce1edd417236d7f84ad
Author: bit9tream <bit6tream@cock.li>
Date:   Sat, 30 May 2020 19:00:34 +0300

rewrite of cool_autostart patch

now it is easier for user to add elements to an `autostart` array

Diffstat:
Mdwm.suckless.org/patches/cool_autostart/dwm-cool-autostart-6.2.diff | 36++++++++++++++++++------------------
Mdwm.suckless.org/patches/cool_autostart/index.md | 14+++++++-------
2 files changed, 25 insertions(+), 25 deletions(-)

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 @@ -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 @@ -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 @@ -233,6 +233,7 @@ static int xerror(Display *dpy, XErrorEvent *ee); @@ -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 */ @@ -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; } @@ -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 @@ -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