Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/commands/helpers/find-free-display.c
blob: 4a071313c184c8c577b2db7a2981ee126b743dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdio.h>
#include <X11/extensions/Xrandr.h>

int main(int argc, char **argv)
{
    int port;

    for (port = 99; port < 1000; port++) {
        char display_name[255];

        sprintf(display_name, ":%d", port);
        Display *dpy = XOpenDisplay(display_name);

        if (!dpy) {
            printf(display_name);
            return 0;
        } else {
            XCloseDisplay(dpy);
        }
    }

    printf("No free display found");

    return 0;
}