You are not logged in.
Hey guys,
I need my application get invoked while my linux box is idle, as in invoking screen saver ?.
What is the logic to figure out the system idle. Any clue much appreciated!!!.
Thanks.
Offline
'ionice -c3' is one way of doing it although the screensaver does it another way: http://www.shallowsky.com/linux/x-screen-blanking.html
Last edited by karol (2011-06-27 10:00:30)
Offline
If you're using XScreenSaver, you can use "xscreensaver-command -time" to figure out if the screen is blanked or not.
Offline
You can make use of X11's screensaver extension to get a system's idle time:
(taken from the code for sinac)
#include <X11/extensions/scrnsaver.h>
static XScreenSaverInfo* xss_info = NULL;
int
seconds_idle(Display *d)
{
if (! xss_info )
xss_info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(d, DefaultRootWindow(d), xss_info);
return xss_info->idle / 1000;
}
Of course, that only gives you the duration of the idle time. To do something after a specified timeout of x seconds, you could make use of a loop that checks the time spent idle, then sleeps for (x - seconds_idle(d)) seconds. On the next iteration of the loop, if the system has been idle long enough, whatever action you want to do can be triggered.
I don't know what you're coding this in, though.
Offline