How to detect keyboard and mouse idle time under Linux…

Hi,

I was searching to do this today. My first aproach was to code something in C with XScreenSaver (man 3 XScreenSaver) but the straightforward way IMHO is this one in perl :
# cpan -i X11::IdleTime; sleep 2; perl -MX11::IdleTime -e 'print GetIdleTime(), $/;'