Check keyboard and mouse activity

I need help from someone that is good at making scripts. I'm trying to make a script file that checks for keyboard and mouse activity during 1 am to 8 am and logs you off if it detects activity. I can't find anything useful in google.

---------- Post updated 06-30-10 at 12:33 AM ---------- Previous update was 06-29-10 at 11:45 PM ----------

I just realized that the distro I am using is quite important for this. I am using Mint. So the command to log me out would be:

gnome-session-save --kill --silent

Does anyone know how to check for keyboard and mouse activity?