I would like to execute a command such as
if my Linux machine has been idle for 5 minutes.
By idle, I mean the same thing a screen saver that gets activated would use to define "idle".
I use a program called
It is a very simple application: it returns the amount of milliseconds since last X interaction:
(note: due to the underlying system, it will consistently give a value in ms slightly lower than the "actual" idle time).
You can use this to create a script that runs a certain sequence after five minutes of idle time via e.g.:
The 100 ms offset is because of the earlier noted quirk that
I have used a similar approach in a Perl script (an irssi plugin) for quite some time, but the above was just written and has not really been tested except for a few trial runs during writing.
Try it by running it in a terminal within X. I recommend setting the timeout to e.g. 5000 ms for testing, and adding
Here's a C application that I found which you can compile.
It needs a couple libraries to build. On my Fedora 19 system I needed the following libraries:
Once these were installed I compiled the above like so:
You can see that it's able to report the number of seconds that X is detecting as idle time by running it like so:
Using this executable you could put together a script that can do something like this, monitoring the idle time reported by
The above shows
NOTE: You could incorporate your