From 87ae18459febb90f8b3b2b3d1b3be064f1cc7b65 Mon Sep 17 00:00:00 2001 From: intexisty <30681593+intexisty@users.noreply.github.com> Date: Wed, 15 Dec 2021 11:34:31 -0600 Subject: [PATCH] Added a check to ensure X is running --- src/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 268c88d..fda32a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include "config/config.h" #include "xdg.hpp" @@ -18,6 +20,16 @@ int main() { Config config(path); #endif + // Check if X is running + Display* disp = XOpenDisplay(NULL); + if (!disp) { + // Can't really start an X window manager without X. + std::cerr << "X is not running, please start X first!"; + return 1; + } + XCloseDisplay(disp); + free(disp); // Not sure if X frees this pointer, going to do it anyways until told otherwise. + // opens connection to display server (xorg) xcb_connection_t* connection = xcb_connect(NULL, NULL);