the previous suggestion also seems like it would work pretty well. some python-like pseudo code:
while "$ xscreensaver-command -exit" fails (indicating screensaver active): present dialog indicating that an active xscreensaver was detected wait for user to unlock screen and respond to dialog perform pam and xscreensaver installation restart xscreensaver daemon -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]