how to tell if mouse/kbd are idle? 

Newsgroups: comp.os.linux.x
Date: Wed, 08 Jan 2003 20:23:47 +0530
> The only thing I need is a way to ask the question: "have my
> mouse and keyboard been idle for 10 minutes?".

If you don't mind C, I have this function that I had written some time back.

#include <X11/Xlib.h>
#include <X11/extensions/scrnsaver.h>
#include <time.h>

char *idle_time() {
XScreenSaverInfo *xsinfo;
Display *dsp;
char *time_str;

struct tm *tim;
xsinfo = XScreenSaverAllocInfo();
dsp = XOpenDisplay(getenv("DISPLAY"));
if(dsp == NULL) {
        printf("Could not open display %s\n", getenv("DISPLAY"));
        exit(1);
}
XScreenSaverQueryInfo(dsp,RootWindow(dsp, XDefaultScreen(dsp)),xsinfo);
XCloseDisplay(dsp);
xsinfo->idle = xsinfo->idle/1000;
tim = gmtime(&xsinfo->idle);
time_str = (char*)malloc(20);
sprintf (time_str, "Idle time: %d:%d:%d", tim->tm_hour, tim->tm_min,
tim->tm_sec
);
return(time_str);
}

Rajesh L G