aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-02-11 03:59:11 -0500
committerDrew DeVault <sir@cmpwn.com>2019-02-11 10:22:53 -0500
commit40023d45a18abb0e177818fa60b8a359680eb3c3 (patch)
tree5130af706e651c60198522070723270c9e2c78ec
parenta5a189cc73941c41f7486ba6bb561ca80dcea601 (diff)
downloadsway-40023d45a18abb0e177818fa60b8a359680eb3c3.zip
sway-40023d45a18abb0e177818fa60b8a359680eb3c3.tar.gz
sway-40023d45a18abb0e177818fa60b8a359680eb3c3.tar.bz2
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.
-rw-r--r--sway/main.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sway/main.c b/sway/main.c
index 12f92bd..b118a18 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) {