summaryrefslogtreecommitdiff
path: root/src/sxwm.c
diff options
context:
space:
mode:
authorwerdl <werdl_@outlook.com>2025-06-01 17:31:29 +0100
committerwerdl <werdl_@outlook.com>2025-06-01 17:31:29 +0100
commite80d59d3ae22bef8aea5282fca64204c6cad1492 (patch)
tree1e9fef6c96c7233dc4a8561aac64d6f3d5ccee05 /src/sxwm.c
parentf869ac4b6038c151f5c89726e17e16db3b90e9b0 (diff)
adjust syntax of exec config keyword
Diffstat (limited to 'src/sxwm.c')
-rw-r--r--src/sxwm.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/sxwm.c b/src/sxwm.c
index c1eeb25..6b98c6b 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -1144,6 +1144,33 @@ void reload_config(void)
fprintf(stderr, "sxrc: error parsing config file\n");
init_defaults();
}
+
+ for (int i = 0; i < 256; i++) {
+ if (user_config.torun[i]) {
+ printf("[DEBUG] executing %s\n", user_config.torun[i]);
+ pid_t pid = fork();
+ if (pid == 0) {
+ char *argv[256];
+ int j = 0;
+ char *arg = strtok(user_config.torun[i], " ");
+ while (arg && j < 256) {
+ argv[j++] = arg;
+ arg = strtok(NULL, " ");
+ }
+ argv[j] = NULL;
+ execvp(argv[0], argv);
+ perror("execvp");
+ _exit(127);
+ }
+ else if (pid > 0) {
+ // parent: don’t wait, just continue (background)
+ }
+ else {
+ perror("fork");
+ }
+ }
+ }
+
grab_keys();
XUngrabButton(dpy, AnyButton, AnyModifier, root);
XGrabButton(dpy, Button1, user_config.modkey, root, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
@@ -1251,6 +1278,32 @@ void setup(void)
fprintf(stderr, "sxrc: error parsing config file\n");
init_defaults();
}
+
+ for (int i = 0; i < 256; i++) {
+ if (user_config.torun[i]) {
+ printf("[DEBUG] executing %s\n", user_config.torun[i]);
+ pid_t pid = fork();
+ if (pid == 0) {
+ char *argv[256];
+ int j = 0;
+ char *arg = strtok(user_config.torun[i], " ");
+ while (arg && j < 256) {
+ argv[j++] = arg;
+ arg = strtok(NULL, " ");
+ }
+ argv[j] = NULL;
+ execvp(argv[0], argv);
+ perror("execvp");
+ _exit(127);
+ }
+ else if (pid > 0) {
+ // parent: don’t wait, just continue (background)
+ }
+ else {
+ perror("fork");
+ }
+ }
+ }
grab_keys();
c_normal = XcursorLibraryLoadCursor(dpy, "left_ptr");