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
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
# CFLAGS / LDFLAGS

View file

@ -16,15 +16,12 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* Autostart */
static const char *const autostart[] = {
"systemctl", "--user", "import-environment", "WAYLAND_DISPLAY", NULL,
"dbus-update-activation-environment", "--systemd", "WAYLAND_DISPLAY", NULL,
"gammastep-indicator", NULL,
"foot", NULL,
"todoodoo", 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 */
};

25
dwl.c
View file

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