Sway clients: Exit gracefully when compositor is unavailable

master
Ryan Dwyer 6 years ago
parent 56c388b510
commit 32ba8154b8

@ -586,7 +586,11 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) {
}
bar->display = wl_display_connect(NULL);
assert(bar->display);
if (!bar->display) {
sway_abort("Unable to connect to the compositor. "
"If your compositor is running, check or set the "
"WAYLAND_DISPLAY environment variable.");
}
struct wl_registry *registry = wl_display_get_registry(bar->display);
wl_registry_add_listener(registry, &registry_listener, bar);

@ -222,7 +222,12 @@ int main(int argc, const char **argv) {
}
state.display = wl_display_connect(NULL);
assert(state.display);
if (!state.display) {
wlr_log(WLR_ERROR, "Unable to connect to the compositor. "
"If your compositor is running, check or set the "
"WAYLAND_DISPLAY environment variable.");
return 1;
}
struct wl_registry *registry = wl_display_get_registry(state.display);
wl_registry_add_listener(registry, &registry_listener, &state);

@ -388,7 +388,9 @@ int main(int argc, char *argv[]) {
state.display = wl_display_connect(NULL);
if (state.display == NULL) {
wlr_log(WLR_ERROR, "Failed to create display");
wlr_log(WLR_ERROR, "Unable to connect to the compositor. "
"If your compositor is running, check or set the "
"WAYLAND_DISPLAY environment variable.");
return -3;
}

@ -908,7 +908,11 @@ int main(int argc, char **argv) {
wl_list_init(&state.surfaces);
state.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
state.display = wl_display_connect(NULL);
assert(state.display);
if (!state.display) {
sway_abort("Unable to connect to the compositor. "
"If your compositor is running, check or set the "
"WAYLAND_DISPLAY environment variable.");
}
struct wl_registry *registry = wl_display_get_registry(state.display);
wl_registry_add_listener(registry, &registry_listener, &state);

@ -342,7 +342,11 @@ static const struct wl_registry_listener registry_listener = {
void swaynag_setup(struct swaynag *swaynag) {
swaynag->display = wl_display_connect(NULL);
assert(swaynag->display);
if (!swaynag->display) {
sway_abort("Unable to connect to the compositor. "
"If your compositor is running, check or set the "
"WAYLAND_DISPLAY environment variable.");
}
swaynag->scale = 1;
wl_list_init(&swaynag->outputs);

Loading…
Cancel
Save