Monitor if a running X session is idle for a while

view story

http://unix.stackexchange.com – Is there any way to monitor if a X session is inactive for i.e 10 minutes? And I would execute a command when it happens, like a screensaver, but it's not a screensaver in this case. (HowTos)