/* prints out details about screens connected to this X display * compile with: * gcc -o enum-displays enum-displays.c `pkg-config gdk-2.0 --cflags --libs` */ #include int main(int argc, char **argv) { GdkDisplay *gdpy; gint i, j, nscreens, nmonitors; GdkScreen *gscreen; gchar *display_name; GdkRectangle geom; gdk_init(&argc, &argv); gdpy = gdk_display_get_default(); nscreens = gdk_display_get_n_screens(gdpy); g_print("This display has %d screen(s).\n\n", nscreens); for(i = 0; i < nscreens; ++i) { gscreen = gdk_display_get_screen(gdpy, i); g_print("Screen %d:\n", i); display_name = gdk_screen_make_display_name(gscreen); g_print(" Name: %s\n Size: %dx%d\n", display_name, gdk_screen_get_width(gscreen), gdk_screen_get_height(gscreen)); g_free(display_name); nmonitors = gdk_screen_get_n_monitors(gscreen); g_print(" %d monitor(s):\n", nmonitors); for(j = 0; j < nmonitors; ++j) { gdk_screen_get_monitor_geometry(gscreen, j, &geom); g_print(" Monitor %d: %dx%d+%d+%d\n", j, geom.width, geom.height, geom.x, geom.y); } } return 0; }