/* gcc -o nvidia-vidmode-crash nvidia-vidmode-crash.c -L/usr/X11R6/lib \ -lX11 -lXext -lXxf86vm */ #define _ISOC99_SOURCE 1 #include #include #include #include int main(int argc, char *argv[]) { XF86VidModeModeInfo **vidmodes; Display *dpy; int screen, maj, min, num; if (!(dpy = XOpenDisplay(NULL))) { fprintf(stderr, "XOpenDisplay() failed\n"); return 1; } screen = DefaultScreen(dpy); maj = min = 0; if (XF86VidModeQueryVersion(dpy, &maj, &min) == False) { fprintf(stderr, "XFree86-VidModeExtension not supported\n"); return 1; } XF86VidModeGetAllModeLines(dpy, screen, &num, &vidmodes); printf("Switching to %dx%d on newline\n", vidmodes[num - 1]->hdisplay, vidmodes[num - 1]->vdisplay); printf("Once the video mode is switched, switch to the console and\n"); printf("wait 5 seconds for the mode to be switched back. Once the\n"); printf("mode is restored, X will remain in the lower resolution,\n"); printf("and will crash when attempting to change the mode again (or\n"); printf("if the mouse leaves the screen to the right or bottom--when\n"); printf("viewport scrolling would normally happen\n"); printf("[enter] to switch\n"); getchar(); XF86VidModeSwitchToMode(dpy, screen, vidmodes[num - 1]); XF86VidModeSetViewPort(dpy, screen, 0, 0); XFlush(dpy); printf("Sleeping for 5 seconds\n"); sleep(5); printf("Restoring video mode\n"); XF86VidModeSwitchToMode(dpy, screen, vidmodes[0]); XCloseDisplay(dpy); return 0; }