detekcia neaktivity
prebrate z
https://bbs.archlinux.org/viewtopic.php?id=121863 , funguje to
#include <X11/extensions/scrnsaver.h>
#include <stdio.h>
int main(void) {
Display *dpy = XOpenDisplay(NULL);
if (!dpy) {
return(1);
}
XScreenSaverInfo *info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
printf("%u", info->idle);
return(0);
}
gcc -o getIdleTime getIdleTime.c -lXss -lX11
idle je v ms, a je to cas od poslednej interakcie - napr. stlacenie klavesy
test:
chmod +x ./getIdleTime
watch -n 10 ./getIdleTime
stlacaj neaku klavesu s sleduj aka je hodnota idle,
zvysok necham na fantaziu citatela