Last active
September 14, 2023 20:36
-
-
Save sulincix/268d0da3e3c07410c3f3cab7929ae5f7 to your computer and use it in GitHub Desktop.
Wait for X11 until ready
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Compile: | |
gcc -o wait_for_x11 wait_for_x11.c -lX11 | |
Run: | |
./wait_for_x11 :0 | |
*/ | |
#include <X11/Xlib.h> | |
#include <unistd.h> | |
int main(int argc, char *argv[]){ | |
Display *dpy; | |
char *name = NULL; | |
if (argc > 1){ | |
name = argv[1]; | |
} | |
while(!(dpy=XOpenDisplay(name))){ | |
sleep(0.3); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment