1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-22 10:26:23 +00:00
org-mode/UTILITIES/x11idle.c
James TD Smith 0410d6460c Add an X11 equivalent to org-mac-idle-seconds.
This needs a small C program (in UTILITIES/x11idle.c) to work.
2009-10-22 15:09:34 +02:00

22 lines
632 B
C

#include <X11/extensions/scrnsaver.h>
#include <stdio.h>
/* Based on code from
* http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/
*
* compile with 'gcc -l Xss x11idle.c -o x11idle' and copy x11idle into your
* path
*/
main() {
XScreenSaverInfo *info = XScreenSaverAllocInfo();
Display *display = XOpenDisplay(0);
//check that X11 is running or else you get a segafult/coredump
if (display != NULL) {
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
}
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
printf("%u\n", info->idle);
return 0;
}