fix runtime autostart even more

This commit is contained in:
Tobias Berger 2024-01-27 20:14:08 +01:00
parent 36b0cf0197
commit 2cc2d1c5ca
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
3 changed files with 16 additions and 18 deletions

View file

@ -5,7 +5,7 @@ include config.mk
# flags for compiling # flags for compiling
DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\"
DWLDEVCFLAGS = -g -pedantic -Wall -Wextra -Wdeclaration-after-statement -Wno-unused-parameter -Wshadow -Wunused-macros\ DWLDEVCFLAGS = -g -pedantic -Werror -Wall -Wextra -Wdeclaration-after-statement -Wno-unused-parameter -Wshadow -Wunused-macros\
-Werror=strict-prototypes -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Wfloat-conversion -Werror=strict-prototypes -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Wfloat-conversion
# CFLAGS / LDFLAGS # CFLAGS / LDFLAGS

View file

@ -16,15 +16,12 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* Autostart */ /* Autostart */
static const char *const autostart[] = { static const char *const autostart[] = {
"systemctl", "--user", "import-environment", "WAYLAND_DISPLAY", NULL,
"dbus-update-activation-environment", "--systemd", "WAYLAND_DISPLAY", NULL,
"gammastep-indicator", NULL, "gammastep-indicator", NULL,
"foot", NULL, "foot", NULL,
"todoodoo", NULL, "todoodoo", NULL,
"firefox", NULL, "firefox", NULL,
"somebar", NULL,
"someblocks", NULL,
"systemctl", "--user", "import-environment", "WAYLAND_DISPLAY", NULL,
"hash", "dbus-update-actifvation-environment", NULL,
"dbus-update-activation-environment", "--systemd", "WAYLAND_DISPLAY", NULL,
NULL /* terminate */ NULL /* terminate */
}; };

23
dwl.c
View file

@ -404,33 +404,36 @@ applybounds(Client *c, struct wlr_box *bbox)
void void
autostartexec(void) { autostartexec(void) {
const char *const *p; const char *const *p;
const char *rp;
size_t i = 0; size_t i = 0;
size_t j;
/* count entries */ /* count entries */
for (p = autostart; *p; autostart_len++, p++) for (p = autostart; *p; autostart_len++, p++)
while (*++p); while (*++p);
/* count runtime entries */ /* count runtime entries */
for (p = autostart_runtime; *p; autostart_len++, p++) for (j = 0; autostart_runtime[j]; j++)
while (*++p); autostart_len++;
j = 0;
fflush(stdout);
autostart_pids = calloc(autostart_len, sizeof(pid_t)); autostart_pids = calloc(autostart_len, sizeof(pid_t));
for (p = autostart; *p; i++, p++) { for (p = autostart; *p; i++, p++) {
if ((autostart_pids[i] = fork()) == 0) { if ((autostart_pids[i] = fork()) == 0) {
setsid(); setsid();
execvp(*p, (char* const*)p); execvp(*p, (char* const*)p);
die("dwl: execvp %s:", *p); die("dwl: execvp %s autostart failed:", *p);
} }
/* skip arguments */ /* skip arguments */
while (*++p); while (*++p);
} }
for (p = autostart_runtime; *p; i++, p++) {
for (rp = autostart_runtime[0]; autostart_runtime[j]; j++, i++) {
if ((autostart_pids[i] = fork()) == 0) { if ((autostart_pids[i] = fork()) == 0) {
setsid(); setsid();
execvp(*p, (char *const *)p); execl(rp, rp, NULL);
die("dwl: execvp %s:", *p); die("dwl: execvp %s autostart runtime failed:", rp);
} }
/* skip arguments */
while (*++p);
} }
} }
@ -2826,7 +2829,7 @@ main(int argc, char *argv[])
int c; int c;
char *path = calloc(8192, sizeof(char)); char *path = calloc(8192, sizeof(char));
int autostart_runtime_idx = 0; size_t autostart_runtime_idx = 0;
strcat(path, getenv("PATH")); strcat(path, getenv("PATH"));
while ((c = getopt(argc, argv, "e:p:s:hdv")) != -1) { while ((c = getopt(argc, argv, "e:p:s:hdv")) != -1) {
@ -2839,8 +2842,6 @@ main(int argc, char *argv[])
else if (c == 'e') { else if (c == 'e') {
autostart_runtime[autostart_runtime_idx] = optarg; autostart_runtime[autostart_runtime_idx] = optarg;
autostart_runtime_idx++; autostart_runtime_idx++;
autostart_runtime[autostart_runtime_idx] = NULL;
autostart_runtime_idx++;
} }
else if (c == 'd') else if (c == 'd')
log_level = WLR_DEBUG; log_level = WLR_DEBUG;