Skip to content

Instantly share code, notes, and snippets.

@sulincix
Last active September 14, 2023 20:36
Show Gist options
  • Save sulincix/268d0da3e3c07410c3f3cab7929ae5f7 to your computer and use it in GitHub Desktop.
Save sulincix/268d0da3e3c07410c3f3cab7929ae5f7 to your computer and use it in GitHub Desktop.
Wait for X11 until ready
/* 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