detecting keyboard, mouse activity in linux

Afroz picture Afroz · Oct 21, 2008 · Viewed 18.4k times · Source

I need a way to detect mouse/keyboard activity on Linux. Something similar to what any IM program would do. If no activity is detected for, say 5 minutes, it will set your IM status to "I'm not here right now".

Any help towards this is appreciated.

Thanks.

Answer

rosch picture rosch · Sep 6, 2011

Or simply use the command xprintidle which returns the idle time in milliseconds.

It has been packaged for debian based systems. (the source is not available any more on the original site dtek.chalmers.se/~henoch but you can get it at packages.ubuntu.com)

more info on freshmeat.net