Read Me - NMS v2.0

Overview

NMS v2.0 consists of a a small background application NMSd that forces system sleep some interval following activation of the Screen Saver plus the NMS Sleep Assist installation and setup application. NMS runs as a user process and works best on system with one user. It has been tested ONLY in Tiger as of this point.

NMS does not actually modify any of the sleep or Energy Saver settings nor does it install any files. NMS simply runs in the background and watches for the Screen Saver as a trigger to issue a sleep command. If normal sleep is partially or mostly functional NMS merely to backstop it only forcing sleep when normal sleep fails, or it can be used to replace normal sleep entirely.

Why I Made This

I live on my laptop and a huge pet peeve of mine is laptop Insomnia.  On every Apple laptop I have used, even before OS X (although sleeping then was so unstable it was not really an issue), after some period os use automatic sleep fails, and usually pretty quick. It can usually be restored with some combination of permissions repairs, combo-udpate re-installs, OF resets, and/or power manager resets but it is a pain and eventually it progresses to the point where it cannot be fixed without a wipe and reinstall. 

Not using my laptop HARD is not an option, but having it run out of juice frequently because I had to run off, or got caught on the phone, etc... is just not cutting it.

What I want is simple.  I want my OS X laptop to Sleep absolutely reliably when on battery power so I never have to think about it,  or fix it,  but I want it to never sleep on AC.  I dont want the solution to be complicated (those fail too), and I want it to be cheap (or free).

I want Bulletproof and Cheap!

NMS is my answer and although it sounds hokey it actually works great.  Basically since the Screen Saver always starts on time I wrote a little background (invisible) app that watches for it, waits a bit, and then issues a normal Sleep command exactly like if you selected Sleep from the Apple menu. Its SLEEP DAMMIT and it works.

I used NMS for a while in Panther and my laptop ALWAYS went to sleep (on Battery) within 6 minutes (but never on AC) and it was great so I decided to package it and release it since know this is a problem for others as well. (I am not a programmer...this is purely a hobby and giving to the Mac community)

That version was very simple with no options. It forced sleep within three minutes of the Screen Saver (that was somewhere randomly form three to six minutes after idle). Given that the OS X Screen Saver cannot bet set to less than three minutes  itself that means my laptop would sleep reliable in six minutes or less.

As far as Battery vs AC I just wrote NMS where it only forced sleep if the Power Source in use at that time WAS	 NOT set to never sleep at the time.  I set Battery to sleep sometime, and AC to sleep never.

THen TIger came along and broke it but I was busy.  However I finally got sick of the insomnia,  got a flurry of emails asking about it, so Iooked at it and changed the one line of code required. Now it works in Tiger. (Released as v1.11)

However to make NMS more useful and flexible so others might get more benefit I enhanced a new version  a bit with some obvious improvements.

Specifically I added:

•	Changed so sleep is forced exactly on the the set idle time interval rather than in the range of the intervall. If its 140 seconds then it Sleeps 140 seconds after the Screen Saver starts.

•	Added an AppleScript Studio based Setup and Configuration wrapper application.

•	Added easy install and uninstall (Install makes it a login item)

•	Options to dynamically START and STOP the background process at will from the wrapper application.

•	Options to set which Power Sources it is active for: AC, Battery, or both with no relation to actual sleep settings.

•	Option to change its idle time interval (the delay between the Screen Saver and sleep).

•	Option to set the Screen Saver idle-time to less than 3 minutes.

It should now be pretty versatile for people who just want a desktop or laptop to sleep reliable and predicable and this is about as far as I am going to take this.  It works and its simple. 

This version is a beta and likely to have bugs. I have only tested it in Tiger since I don't have easy access to Panther.  I will make it Panther compatible as well.

Installation and Setup

1)	Before installing NMS copy the NMS Sleep Assist application to your Applications folder. The Login item it linked to a file inside and although it should not lose it with moving around the application I would put it where you want it and leave it there.

2)	Thne NMS Sleep Assist to Install and Activate NMSd (the actually background app). NMS Sleep Assist should also be able to uninstall all prior versions except ? v1.0, which it should remove but I haven't tested it yet.

3)	Choose the power sources you want NMSd force sleep while using.  Do you want sleep forced only when on Battery Power, or only on AC Power, or to you want sleep forced for both?

4)	If desired you can change the NMSd Idletime (the interval between Screen Saver activation and NMSd forcing sleep) and the Screen Saver Idletime (from NMS you can set it to values as low as 60 sesonds)
	The default setting for NMSd Idletime is 180 seconds (3 minutes)
	Note  -	Total Idletime Until Forced Sleep  =  Screen Saver idletime +  the NMSd Idletime.

5)	Quit the NMS Sleep Assist application and get on with life.

Tips and Information

Use the NMS Sleep Assist application to manually START or STOP the NMSd process at any time (you do not need to logout or restart for any changews).  Of course you can use it to change which NMS active power sources, or change the the iidle timing of the Screen Saver orr the NMSd process. The Screen Saver setting is the same one in the Screen Saver preference and setting it there resets essentially resets it.

I use NMS to replace my build in sleep functionality but If regular system sleep usually works but fails intermittently you can use NMS to backstop it.  For example if normal sleep is set to 5 minutes you can set the screen saver for 6 minutes and NMS to force sleep 1 minute later.  If your system fails to sleep at 5 minutes NMS will force sleep at 7 minutes.

Since the NMSd process is a normal user process it only works only when the user running it is actually logged in and then it can only force sleep if the that user is the front active user. 

Important: (For better or worse) NMS will not force sleep while running from a logged user but not active user cycled to the background via rapid user switching. In other words NMS will rain forced sleep events on an active user while running for a background user.

In the same way NMSd has no activity while at the login screen. 

You can confirm it is working by viewing the logs at ~/Library/Logs/NMSv2_0 run.log and looking for the entry "forcing sleep". You cab open the logs from controls in NMSd Preferences.

Safety and Security

NMS is as safe and un-intrusive as I can make it. Except you copying NMS to your HD and it creating its single preference file in your User Preferences folder it does not copy or create any files anywhere in your system.  All its files are contained within it and run from the single NMS Sleep Assist application. The only preferences (besides its own) that NMS optionally modifies is the Screen Saver idle time and the login preference by the act of adding a new login item. Otherwise NMS alters No system settings of any kind including any settings related to sleep or Energy Saver. NMS runs and lives completely in user space and will never ask for your Admin password or touch any files outside of the home folder of the the user.

Resource Use

When I looked at it in Panther the NMSd application (while running in the background) had so measurable or appreciable impact in system performance either subjectively or with benchmarks. If  the NMSd Idletime is set very low (like a few seconds) that might change so I probably wouldn't do that.

If Problems Arise

NMS should not harm your system.  If you have any problems or questions please email me and I will help all I can. Please do not become convinced NMS has done something and erase your hard drive. Send me an email and I will (I hope) fix the issue.

Contact, More Info, Website...

You can email me at rwikoff@mac.com

I have given NMS a page on my server at http://slicedapple.ath.cx/nmsutility.html

I have a hobby Mac-centric web site on a hobby server at http://slicedapple.ath.cx/.  A mostly up-to-date mirror is maintained on .mac at http://homepage.mac.com/rwikoff/slicedapple/.

Ass Covering Stuff....

Liscense, Warnings, Disclaimer

This software is beta and released released AS IS WITHOUT ANY SUPPORT OR WARRANTY.  If is messes up you computer, has an affair with your wife, or destroys your life then you were warned.

This is released as "What_the_Hell_Ware". It is free (as in beer...warm generic beer...but free beer) and may be distributed and modified without limit provided this Read Me including this disclaimer, license, and warning accompany it.

If you use it and had fun, or thought is was a little cool, send me an email.  If you thought it was stupid, well, you don't have to send an email...really.

Version History

v2.0

This version. Basically an enhanced form of the v1.5 build with an AppleScript Studio GUi and with some sleep preventing bugs fixed along with some enhanced error handing for the NMSd process,.  This version also gained the ability to specifically set which power sources are used.

v1.5

This is a more extensive update with some simple changes and enhancements I have been meaning to add and it just a place holder and interim build to get the code ready to place in an AppleScript Studio front end. This version has ONLY been tested in Tiger (as that is all I have right now) but may work just fine in Panther.

	•	Expands the Settings application (just about too much for straight AppleScript) to distinguish between the various states of having a startup item set and/or the background process running and provides relevant options. 
	•	Limited recognition of Pre-Tiger version with "upgrade" in place. Also has options to change the time to NMS force sleep and set the screen saver idle time to less than 180.
	•	The actual background process has been upgraded so that it now forces sleep at the specified interval rather than any time within the interval.

v1.11

This is a quick update that make a small change to the background process to allow Tiger support. This version MAY work in Panther but I don't have any systems that still have 10.3 on them. 

Specifically this fixes the failure to recognize a Never Sleep setting in Tiger but is otherwise unchanged from v1.1.

 v1.1

This revision includes a wrapper application to handle activating and deactivating NMS so that the user doesn't have to worry about how to quit generically named background apps or how to add/remove login items manually.  

It also handles quitting the monitoring applet  (now named NMSd) in such a way as to not kill other applets. Only ested on 10.3 Panther.  Certainly the dialogs are far too long for 10.2.

v1.0

Original release which was just the bare background app (just called NMS) that the user could double click to launch (but killing it short of a logout was harder for less techy people) and that had to be manually added to the login item.

July 17, 2005