I'd suggest writing some kind of X hooks or something to check for mouse/keyboard activity (I'm sure there are utilities out there already), and potentially modifying dwm to keep track of time each window is focused (or something similar), maybe even focused when there is keyboard activity. Definitely feels kludgy than taking a screenshot, at least to me.
-- Samuel Baldwin - logik.li