Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'I finally got Sleepwatcher to work ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
I finally got Sleepwatcher to work
Authored by: tomhayes on Dec 16, '09 02:49:05PM

I recently purchased a SmartStrip power outlet for my computer setup to turn off devices when the computer went to sleep.

It worked - except for my Hitachi Simpletech 2GB drive. The external drive has a "power on auto" feature where you plug it into the wall and then into to the computer and only when both the wall outlet and the computer are on does the drive come on.

When the computer went to sleep the Powerstrip would turn off power to the hard drive and the USB port on the Mac would sense that the drive was removed and it would trigger some sort of event where the computer would immediately wake from sleep and I'd get a Device Removal Warning.

I then plugged the external drive into one of the "Always Powered" outlets, but it had the same issue.

I downloaded SleepWatcher (http://www.bernhard-baehr.de/) and installed SleepWatcher and the Sleepwatcher start-up items program.

I created a file in my home directory as named .sleep and chmod r+x it. (note this thread kept talking about Desktop/.sleep , it should be in your home directory which is commonly refereed to as "~" or something like /bootdrive/usr/yourusername)

.Sleep contained the following command:
osascript -e 'tell application "Finder" to eject "2TB"'

Where 2TB was the name of my external drive.

When the computer went to sleep Sleepwatcher started and finder started to eject the drive and the computer went to sleep. The drive did not completely unmount before the computer went to sleep and it triggered some event that would wake up the Mac. The external drive would turn on and mount again with the Device Removal Warning effectively stopping sleep.

So I modified .sleep to contain:
osascript -e 'tell application "Finder" to eject "2TB"'
osascript -e 'tell application "Finder" to delay 10'

Now the drive unmounts, finder waits 10 seconds and then the computer sleeps. It works like a charm.

I created a file called .wakeup that contains:
#!/bin/bash
backupsVolume=`diskutil list | awk '/ 2TB / {print $6}'`
if [ ! -z "$backupsVolume" ]
then
diskutil mount $backupsVolume
fi

This mounts the drive when the computer wakes from sleep.

Thank you to Sleepwatcher, this thread, and Finity.org (http://www.finity.org/node/41) for helping me with this.

P.S. I am running this on a Mac pro with Snow Leopard.



[ Reply to This | # ]