upload pod file
[hband-tools.git] / compiled-tools / xidle.c
blobf11127412f0adab01432529664da1f19594e4416
2 #include <time.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
7 #include <X11/extensions/scrnsaver.h>
9 int GetIdleTime()
11 time_t idle_time;
12 static XScreenSaverInfo *mit_info;
13 Display *display;
14 int screen;
16 mit_info = XScreenSaverAllocInfo();
17 if((display=XOpenDisplay(NULL)) == NULL) { return(-1); }
18 screen = DefaultScreen(display);
19 XScreenSaverQueryInfo(display, RootWindow(display,screen), mit_info);
20 idle_time = (mit_info->idle) / 1000;
21 XFree(mit_info);
22 XCloseDisplay(display);
23 return idle_time;
26 int main()
28 int idle = GetIdleTime();
29 if(idle == -1) return 1;
30 printf("%d", idle);
31 return 0;