First connect to X, then create the socket

Fixes #519.
This commit is contained in:
Bastien Dejean 2016-07-17 16:26:33 +02:00
parent 5c447f7ca4
commit cfe5e42452

40
bspwm.c
View file

@ -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);