diff --git a/contrib/autorandr_launcher/autorandr_launcher.c b/contrib/autorandr_launcher/autorandr_launcher.c index 80d86f0..8e1b878 100644 --- a/contrib/autorandr_launcher/autorandr_launcher.c +++ b/contrib/autorandr_launcher/autorandr_launcher.c @@ -42,10 +42,13 @@ __attribute__((format(printf, 1, 2))) static void ar_log(const char *format, ... static int ar_launch(void) { + static const char *argv[] = { AUTORANDR_PATH, "--change", "--default", "default", NULL}; + char **comm = malloc(sizeof argv); + memcpy(comm, argv, sizeof argv); + pid_t pid = fork(); if (pid == 0) { - static char *argv[] = { AUTORANDR_PATH, "--change", "--default", "default", NULL}; - if (execve(argv[0], argv, environ) == -1) { + if (execve(argv[0], comm, environ) == -1) { int errsv = errno; fprintf(stderr, "Error executing file: %s\n", strerror(errsv)); exit(errsv); @@ -54,6 +57,7 @@ static int ar_launch(void) exit(127); } else { waitpid(pid, 0, 0); + free(comm); } return 0; } @@ -154,12 +158,8 @@ int main(int argc, char **argv) xcb_generic_event_t *evt; while ( (evt = xcb_wait_for_event(c)) ) { ar_log("Event type: %" PRIu8 "\n", evt->response_type); - ar_log("screen change masked: %" PRIu8 "\n", - evt->response_type & - XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE); - if (evt->response_type & - XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE) { + if (evt->response_type) { xcb_randr_screen_change_notify_event_t *randr_evt = (xcb_randr_screen_change_notify_event_t *) evt; time_t evt_time = time(NULL);