In a desktop application, I need to detect monitor resolution from time to time. The code is like:
Display *d;
Screen *s;
d = XOpenDisplay(":0");
if (NULL == d) {
g_print("XOpenDisplay failed\n");
return;
}
s = DefaultScreenOfDisplay(d);
if (NULL == s) {
g_print("DefaultScreenOfDisplay failed\n");
return;
}
g_print("Display size: %dx%d\n", s->width, s->height);
But another requirement needs me to turn off lightdm service and X server too, which this piece of code depends on.
Is there other method to detect resolution without Xlib support? Thanks