mirror of https://github.com/SeanOMik/swm.git
Added a check to ensure X is running
This commit is contained in:
parent
6bbdfb3baf
commit
87ae18459f
12
src/main.cpp
12
src/main.cpp
|
@ -4,6 +4,8 @@
|
|||
#include <xcb/xcb.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue