diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-05 13:42:04 +0900 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-04-05 13:42:04 +0900 |
commit | 87e15e8f3d6b687bc256712b5f5cbcd2bb3bcd75 (patch) | |
tree | dc545991d626576750e815b9cc7a84a198541102 /cbits/getidletime_posix.c | |
parent | 330a4f9562f9e71ebf680451b8ed78790b103f30 (diff) | |
download | srem-idleuser.tar.gz |
start trying to detect idle user under X11idleuser
Can't make it build yet
Diffstat (limited to 'cbits/getidletime_posix.c')
-rw-r--r-- | cbits/getidletime_posix.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cbits/getidletime_posix.c b/cbits/getidletime_posix.c new file mode 100644 index 0000000..95eb062 --- /dev/null +++ b/cbits/getidletime_posix.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <X11/extensions/scrnsaver.h> + +/* Based on getIdleTime.c by falconindy on ArchLinux BBS thread ID + 121863. This function connects to the display in the DISPLAY + environment variable and returns the idle time. So the Haskell + code is responsible for determining and setting DISPLAY if + e.g. running from cron. */ + +int GetXIdleTime () +{ + Display *dpy = XOpenDisplay(NULL); + + if (!dpy) + { + return(-1); + } + + XScreenSaverInfo *info = XScreenSaverAllocInfo(); + XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info); + + return (info->idle); +} + +/* int main (void) +{ + int idletime; + + idletime = GetXIdleTime(); + printf("%u", idletime); + return 0; +} */ |