Idle detect on multiple X servers

Yan Seiner yan at
Thu Jan 12 12:14:03 PST 2012

I have a kiosk that runs several applications on different VTs.  At boot I
start multiple X instances, each on its own vt.  The users can switch
between apllications by the CTRL-ALT-Fn combination.  This works fine.

Now I've been asked to rotate through the displays when the system has
been idle for some time.  this means that I have to detect activity on any
of the vts.  All of the vts run as the same user.

What's the best way to do this?

Can I do something like this:

// loop through possible displays
    display = XOpenDisplay(n);
// if not NULL
    if (XScreenSaverQueryExtension(display, &event_base, &error_base)) {
	XScreenSaverQueryInfo(display, DefaultRootWindow(display), &info);

	seconds = (float)info.idle/1000.0f;
// if all screens have been idle for more than some number of seconds,
start looping through vts

or is there some better way to do this?

Pain is temporary. It may last a minute, or an hour, or a day, or a year,
but eventually it will subside and something else will take its place. If
I quit, however, it lasts forever.

More information about the xorg mailing list