Run a Script When (before) Computer Goes to Sleep

matzh

Registered
Hello,

I would like to run a script when my computer goes to sleep.
Background: I am connected through Cisco VPN to my University and have several drives mounted over smb.
When I shut my Powerbook and don't think of it, the VPN connection is interrupted and the Drives stay mounted in the Finder, however, when I try to access them (also just for eject), the system (or at least finder) becomes unaccessible until a time-out is reached and the drives are ejected.
The script ejects the drives and then disconnects the VPN connection properly.

I have looked into launchd or Startup Items, but I do not think this is what I need (maybe launchd with the watchpath on some files that are modified on sleep, but this may not wait for my script to finish before going to sleep).
I have not found much documentation on the power management and how to access it. Is there an easy way to do this?

Thanks

Matthias

 
Back
Top