From cfe5e4245244e03cfdffb6e7979085ce12118d67 Mon Sep 17 00:00:00 2001 From: Bastien Dejean Date: Sun, 17 Jul 2016 16:26:33 +0200 Subject: [PATCH] First connect to X, then create the socket Fixes #519. --- bspwm.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/bspwm.c b/bspwm.c index df3aed9..dc29c1b 100644 --- a/bspwm.c +++ b/bspwm.c @@ -75,6 +75,26 @@ int main(int argc, char *argv[]) } } + if (config_path[0] == '\0') { + char *config_home = getenv(CONFIG_HOME_ENV); + if (config_home != NULL) { + snprintf(config_path, sizeof(config_path), "%s/%s/%s", config_home, WM_NAME, CONFIG_NAME); + } else { + snprintf(config_path, sizeof(config_path), "%s/%s/%s/%s", getenv("HOME"), ".config", WM_NAME, CONFIG_NAME); + } + } + + dpy = xcb_connect(NULL, &default_screen); + + if (!check_connection(dpy)) { + exit(EXIT_FAILURE); + } + + load_settings(); + setup(); + + dpy_fd = xcb_get_file_descriptor(dpy); + char *sp = getenv(SOCKET_ENV_VAR); if (sp != NULL) { snprintf(socket_path, sizeof(socket_path), "%s", sp); @@ -105,26 +125,6 @@ int main(int argc, char *argv[]) err("Couldn't listen to the socket.\n"); } - if (config_path[0] == '\0') { - char *config_home = getenv(CONFIG_HOME_ENV); - if (config_home != NULL) { - snprintf(config_path, sizeof(config_path), "%s/%s/%s", config_home, WM_NAME, CONFIG_NAME); - } else { - snprintf(config_path, sizeof(config_path), "%s/%s/%s/%s", getenv("HOME"), ".config", WM_NAME, CONFIG_NAME); - } - } - - dpy = xcb_connect(NULL, &default_screen); - - if (!check_connection(dpy)) { - exit(EXIT_FAILURE); - } - - load_settings(); - setup(); - - dpy_fd = xcb_get_file_descriptor(dpy); - signal(SIGINT, sig_handler); signal(SIGHUP, sig_handler); signal(SIGTERM, sig_handler);