Prevent mac from going to sleep immediately after the closing lid
If you mean that you want to be able to close the screen without putting the MBA to sleep, then that's not supported. There is a hack that will prevent sleep:
http://www.macupdate.com/app/mac/22211/insomniax
but as with any such hack, you use it at your own risk (and it's not been updated in a couple of years so it may not work with current Macs). The MBA, while quite capable, isn't designed to run 24/7, so if you never let it sleep, you may encounter heat issues at some point.
If that's not what you mean, please clarify what it is you wish to accomplish.
Regards.
As far as my understanding of the Mac sleep mechanism goes, there are several modes of sleep. The most modern one, the standby mode, is built for immediate wake-up, by leaving the RAM powered up and writing nothing to disk during the first hour of sleep. Only after this hour has passed is the RAM written out to disk and powered-down. Both the write and read operations of the RAM are each said to take about 20-25 seconds.
You could verify the sleep parameters by issuing the command :
pmset -g
Of special interest should be the following parameters :
standbydelay : The delay in seconds until regular sleep goes over to standby mode. The default value is 4200 seconds, or 70 minutes.
hibernatemode : controls the hibernation mode, and its values are as follows :
- 0 - Old style sleep mode, with RAM powered on while sleeping, safe sleep disabled, and super-fast wake.
- 1 - Hibernation mode, with RAM contents written to disk, system totally shut down while “sleeping,” and slower wake up, due to reading the contents of RAM off the hard drive.
- 3 - The default mode on machines introduced since about fall 2005. RAM is powered on while sleeping, but RAM contents are also written to disk before sleeping. In the event of total power loss, the system enters hibernation mode automatically.
Verify that your values are standbydelay=4200 and hibernatemode=3. If you wish to change hibernatemode to 3, this is done as follows :
sudo pmset -g | grep hibernatemode > ~/Desktop/current_mode.txt
sudo pmset -a hibernatemode 3
The first command is just there for being cautious.
There is also the usual advice about ensuring that your Mac and drivers are fully patched.
More information:
Set newer portable Macs' sleep mode
“Fixing” Slow Wake for MacBook Pro W/ Retina Display
I don't know any way to add a delay for going to sleep when the lid of a laptop is closed.
If others search for how to temporarily or permanently prevent sleep when the lid is closed, you can use NoSleep or InsomniaX.