Added a check to ensure X is running

This commit is contained in:
intexisty 2021-12-15 11:34:31 -06:00
parent 6bbdfb3baf
commit 87ae18459f
1 changed files with 12 additions and 0 deletions

View File

@ -4,6 +4,8 @@
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xproto.h> #include <xcb/xproto.h>
#include <X11/Xlib.h>
#include "config/config.h" #include "config/config.h"
#include "xdg.hpp" #include "xdg.hpp"
@ -18,6 +20,16 @@ int main() {
Config config(path); Config config(path);
#endif #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) // opens connection to display server (xorg)
xcb_connection_t* connection = xcb_connect(NULL, NULL); xcb_connection_t* connection = xcb_connect(NULL, NULL);