Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

SleepWatcher - A utility to run tasks on sleep/wake Pick of the Week
The macosxhints Rating:

[Score: 9 out of 10]
This is the Pick of the Week for the week of August 14th

SleepWatcher has been mentioned here in a number of hints -- it's the best way I've found yet to have actions happen on sleep or wake (or even idle). Note that it's not a GUI application, so you'll want to be comfortable in Terminal before trying to put it to use. But with the ability to have different sleep and wake actions per user, as well as a number of different configuration options, SleepWatcher is a powerful tool for those trying to make their Macs behave in a certain manner on sleep or wake.

I'm not going to say much more about it in this writeup; read the linked hints above for some real-world examples of how you can put it to use. If you want control over the sleep and wake activities on your Mac, SleepWatcher is a great solution.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[33,761 views]  

SleepWatcher - A utility to run tasks on sleep/wake | 15 comments | Create New Account
Click here to return to the 'SleepWatcher - A utility to run tasks on sleep/wake' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: wgscott on Fri, Sep 8 2006 at 3:27PM PDT
I don't know how I missed this but I have been looking for years for something like this. Thanks for posting it.

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: FlyBoy on Fri, Sep 8 2006 at 5:18PM PDT
And the developer has always been very responsive. Great little utility! Thanks for selecting this as it deserves recognition.

FlyBoy

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: daGrimm on Sat, Sep 9 2006 at 1:26AM PDT
"so you'll want to be comfortable in Terminal before trying to put it to use"
Could anyone recommend me a lightweight, easy-to-use introduction to terminal? I do maybe know some very basic commands, but would like to be more comfortable with it. Is there some page or node or anything for noobs to get started? Thanks a lot.

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: FlyBoy on Sat, Sep 9 2006 at 8:42AM PDT
Search on Google (or the search engine of your choice) for "bash tutorial." Bash is the shell program that runs by default in Tiger's Terminal.app. In very basic terms, consider the "shell program" to be to the Terminal, what the "Finder" is to the Mac. It lets you look at the contents of directories, copy, move and delete files, launch programs, and a whole lot more. Unlike the Finder, the shell operates only with text commands.

Here's an example tutorial on the web for bash: http://www.hypexr.org/bash_tutorial.php

Hope this helps,

FlyBoy

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: wgscott on Sat, Sep 9 2006 at 11:39AM PDT
I've actually put together a web page called Unix Links for just this question. I hope it is useful.

[ Reply to This | # ]
Unix FAQ for OS X
Authored by: hayne on Tue, Dec 12 2006 at 12:24AM PST
See this FAQ about using Unix commands on OS X:
http://forums.macosxhints.com/showthread.php?t=40648

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: ADent on Sat, Sep 9 2006 at 9:45PM PDT
Does this allow you to do anything useful if your Mac is set to require a password?

(Typ it wakes up for 30-45 sec waiting for a password, then goes back to sleep if no one is there to enter a password).

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: GlowingApple on Sun, Sep 10 2006 at 1:03PM PDT
I have mine set to mute my laptop's sound when I put it to sleep. That way if I bring my laptop to a library, class, meeting, etc I don't have to worry about my laptop making any noise when I wake it. Works fine, with a screensaver and password.

---
~Jayson <www.kempinger.homelinux.net>

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: dtrevas on Mon, Sep 11 2006 at 6:10AM PDT
If this requires that you know how to use Terminal, why is it better than "pmset?" If you like the Terminal, open it up and type: man pmset and look at all you can do. It really, umm, ticks me off that the Energy Saver/Schedule Preference only allows one pair of wakeorpoweron/(sleep or shutdown) times. After all, it is the official GUI interface with pmset. With pmset, you can do anything you want! I was hoping someone was going to come up with a nice GUI app for this, but I might just have to do it myself, and it won't be pretty!

[ Reply to This | # ]
SleepWatcher - A utility to run tasks on sleep/wake
Authored by: Lliwynd on Sun, Nov 16 2008 at 3:23PM PST

I just went searching for pmset documentation to see if I could get sleepwatcher functionality without a new install.

It seems that pmset and sleepwatcher do different things. pmset is a command-line tool for the energy saver prefs. It allows you to schedule a wake or sleep event. pmset does not seem to allow you to set a specific script or program to run on wake. sleepwatcher adds this capability.



[ Reply to This | # ]
How I use SleepWatcher
Authored by: kahuna on Mon, Sep 11 2006 at 8:42AM PDT
I use ncidd as my caller-id log on a linux server. On my PowerBook, I have an ncid client that talks to ncidd and displays name, number and thumbnail image from Address Book when a call is received. However, the client-server connection is broken after a sleep-wake cycle. With SleepWatcher, I restart the ncid client everytime the PowerBook wakes. Maybe not as elegant as fixing the client, but I'm not a programming genius.

[ Reply to This | # ]
Sleep sound on my PowerBook
Authored by: victory on Tue, Sep 12 2006 at 11:45AM PDT
I use SleepWatcher to play a sound every time my PowerBook goes to sleep. In particular, my .sleep script basically invokes a cmd-line sound player app* such as found here or here. (Experienced AppleScripters could probably do some similar magic with osascript or something.) The sound I have the PowerBook play comes from here.

Yes, it's silly. Yes, it's stupid, but besides making me laugh, it actually does has a practical effect -- it tells me that the PB has shut down successfully before I tuck it away in a carrying case and begin hefting it around. In the past, I've run into a sporadic problem of the PB not sleeping properly when I closed the lid. This created a problem with trapped heat and increased the risk of toting around a unit that I thought was safely asleep that wasn't.

---

* BTW, if you are a user of the excellent TextMate text-editor from MacroMates.com, there's an (apparently) undocumented cmd-line sound app already tucked away inside it. Hint: TextMate/TextMate.app/Contents/SharedSupport/Support/bin/play)

[ Reply to This | # ]

Automatically establish internetconnections via the Cisco VPNClient on start- and wake-up
Authored by: Sito on Fri, Oct 20 2006 at 7:56AM PDT
I was annoyed by always being forced to reestablish the Internetconnection by the Cisco-GUI after waking up my machine. Now, by the help of SleepWatcher (btw: thanx for the great hint and thanx for the software) the connection is always being reestablished automatically w no need of using the GUI anymore. Here is, what I did:

1. Installed the Files "SleepWatcher" and "SleepWatcher StartupItem" from the downloaded SleepWatcher File.

2. Wrote a little script (I used Textedit) containing just the following two lines:

#!/bin/sh
vpnclient connect PROFILE
(whereas PROFILE has to be replaced by the Name of the File your Cisco VPNClient works with located in …/private/etc/opt/cisco-vpnclient/Profiles/ – btw the path is invisible but can be made visible with e.g. MacExplorer)

3. Saved the such created Texteditfile as ".wakeup" (w/o anything written before the stopmark and w/o the quotes) in my Homedirectory where it is being placed as an invisible file (but with e.g. MacExplorer easily to find if you need to edit it).

4. Opened the Terminal and made the ".wakeup"-file an executable Unix-file by typing the following line:

chmod +x /Users/MYNAME/.wakeup

(whereas MYNAME has to be replaced by the name of your Homedirectory).

5. Restarted my machine.

And that did it. Now, whenever I startup my machine or wake it up, the internetconnection is automatically being (re)established. Another advantage: You won´t need the Cisco-GUI anymore and therefore will have a bit more space in your dock for something else ;-)

[ Reply to This | # ]

Automatically establish internetconnections via the Cisco VPNClient on start- and wake-up
Authored by: Sito on Fri, Oct 20 2006 at 8:48AM PDT
Forgot one thing to mention: This hint only works if there is no prompt for your password on login to the Cisco-Network. To get rid of the prompt, there will be some editing necessary on the Connection-Profile placed in the folder …/private/etc/opt/cisco-vpnclient/Profiles/ (you can browse hidden folders with e.g. MacExplorer):

1. Shut down the VPN-Connection and quit the GUI (because it will override all of the following, when being closed later).

2. Open the YourProfile.pcf in e.g. Textedit (whereas "YourProfile" is the Profilename the Cisco-GUI shows when connecting).

3. Find the line Username= and make sure that your Username as distributed by your admin is entered there.

4. Find the line SaveUserPassword. If the value is set to =1 and your username (step 3) was already entered, everything is fine and you can use the former posted hint. But if the value is set to =0, set the value to =1 and go on with the following steps.

5. Now, find the line UserPassword and behind the = type in your personal userpassword you got from the admin.

6. Close Textedit and browse to the file (YourProfile.pcf (see above)) in the folder named above (again with e.g. MacExplorer).

7. Select the pcf-file you just edited and press command-i to get the file information.

8. Make sure the item "locked" is being highlighted. This way your editing won´t be lost after using the Cisco-GUI at a later time.

Now, the former posted hint should work. To make sure, that your editing was fine you might want to use the Cisco-GUI to see if you got rid of the prompt for your account and your password.

[ Reply to This | # ]

Enable/disable Energy Saver's disk sleep
Authored by: mattmoss on Tue, Oct 14 2008 at 1:21PM PDT
I found that an external FW800 hard drive I have (used only for Time Machine) was being put to sleep by the OS, only to be awoken 5 minutes later by the OS. The hard drive is usually quiet except when it spins up, and this periodic noise was rather annoying (and I don't imagine is all that good for the disk either, to be spun down and back up every 10 minutes).

Turning off Energy Saver's control of disk sleep (via System Prefs) didn't help... It worked great while using the iMac, but for some reason when I put the machine to sleep, it would wake up within 10 minutes, presumably because the drive was no longer being put to sleep. (Don't know why that should happen, but it does.)

I tried tinkering with the disksleep parameter of pmset, to change the interval, but with no better results.

Now, I have modified the rc.sleep and rc.awaken scripts from SleepWatcher to run pmset -c disksleep 10 (rc.sleep) and pmset -c disksleep 0 (rc.awaken). Everything seems happy!

[ Reply to This | # ]