From 40023d45a18abb0e177818fa60b8a359680eb3c3 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Mon, 11 Feb 2019 03:59:11 -0500 Subject: [PATCH] Abort early when XDG_RUNTIME_DIR is not set This aborts sway and displays an error message about XDG_RUNTIME_DIR not being set without initializing the wl_display or logging any other information. --- sway/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sway/main.c b/sway/main.c index 12f92bd80..b118a1823 100644 --- a/sway/main.c +++ b/sway/main.c @@ -299,6 +299,14 @@ int main(int argc, char **argv) { } } + // Since wayland requires XDG_RUNTIME_DIR to be set, abort with just the + // clear error message (when not running as an IPC client). + if (!getenv("XDG_RUNTIME_DIR") && optind == argc) { + fprintf(stderr, + "XDG_RUNTIME_DIR is not set in the environment. Aborting.\n"); + exit(EXIT_FAILURE); + } + // As the 'callback' function for wlr_log is equivalent to that for // sway, we do not need to override it. if (debug) {