logo

inaban

Unnamed repository; edit this file 'description' to name the repository.
commit: d412604e90d79e1abb4838a08f5c6fee4ad27fb5
parent: 7dc421a47eb6e16012bb98e7c9680df172936fa1
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  8 Oct 2019 03:42:54 +0200

inaban.c: allow multiple -s options

Diffstat:

Minaban.c16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/inaban.c b/inaban.c @@ -637,14 +637,18 @@ int main(int argc, char *argv[]) { wlr_log_init(WLR_DEBUG, NULL); - char *startup_cmd = NULL; + char *startup_cmdv[] = {NULL}; + int startup_cmdc = 0; int c; while((c = getopt(argc, argv, "s:h")) != -1) { switch(c) { - case 's': startup_cmd = optarg; break; + case 's': + startup_cmdv[startup_cmdc] = optarg; + startup_cmdc++; + break; default: usage(argv[0]); return 0; } } @@ -776,9 +780,13 @@ main(int argc, char *argv[]) /* Set the WAYLAND_DISPLAY environment variable to our socket and run the * startup command if requested. */ setenv("WAYLAND_DISPLAY", socket, true); - if(startup_cmd) + for(int i = 0; i < startup_cmdc; i++) { - if(fork() == 0) execl("/bin/sh", "/bin/sh", "-c", startup_cmd, (void *)NULL); + if(fork() == 0) + { + unsetenv("DISPLAY"); + execl("/bin/sh", "/bin/sh", "-c", startup_cmdv[i], (void *)NULL); + } } /* Run the Wayland event loop. This does not return until you exit the * compositor. Starting the backend rigged up all of the necessary event