Login / Off Script

Trying to get this script to work with a USB thumb drive. It works to log you out when the drive is removed but i cant get it to log me back in when the drive is reinserted.

any ideas’s on how i can get this script to run behind the screen saver?

repeat

tell application "Finder" to if exists "/Volumes/Jeff/LOGIN12353423!@$.rtf" as POSIX file then
	delay 2
	tell application "System Events"
		tell security preferences
			set require password to wake to false
		end tell
	end tell
	
	tell application "ScreenSaverEngine" to quit
	
else
	
	tell application "System Events"
		tell security preferences
			set require password to wake to true
		end tell
	end tell
	
	activate application "ScreenSaverEngine"
end if

end repeat

Browser: Safari 534.30
Operating System: Mac OS X (10.6)

Hi,

Any USB activity wakes up the computer or stops the screensaver, so I guess the password dialog will appear before your script will detect the drive as mounted

is there any way around this?

Turn auto mount off of your USB drive which means that you have to mount all USB drives by hand which I don’r recommend to do unless you’re a console/single-user user like me.

any other ideas to make this script work, is there any power settings i can mess with you make the drives mount in the background