The Energy Saver pane in System Preferences does not give you full access to all the capabilities of your Mac. Even desktop models have more than a dozen different controls to determine their sleep and related behaviours. The best way to gain full access, whether you’re trying to fix your Mac’s aberrant sleeping habits, or tweak something crucial, is to use
pmset at the command line.
Macs differ in their power management capabilities, so the first command that you’ll need is
pmset -g cap
which lists what is available. On this iMac17,1, it runs to
Capabilities for AC Power:
There is an additional system-wide power setting,
DestroyFVKeyOnStandby, which determines whether the FileVault key is destroyed when your Mac goes into standy or hibernate mode. Normally that is set to 0, which preserves the key, but if you want to secure your encrypted hard disk, you will probably want to set it to 1: then waking it from hibernation will require the user to enter the FileVault passphrase, and if they fail to do so, they cannot try to recover the key from memory.
The meaning of these settings is generally obvious:
displaysleepis the time in minutes before the display is put to sleep; 0 indicates that the display is never put to sleep;
disksleepis the time in minutes before hard disks are spun down and put to sleep; 0 means never;
sleepis the time in minutes to system sleep; 0 means never;
wompis 1 if you want your Mac to wake when it receives a ‘magic’ network packet, which is the same as wake for network access in the pane;
autorestartsets whether your Mac will automatically restart when power loss has occurred and power has been restored;
halfdimsets whether an intermediate (rather than full) dimming is used for display sleep;
gpuswitchsets GPU behaviour during sleep, and appears to be undocumented;
standbysets whether to hibernate when a Mac has been asleep for a set period; this writes memory to disk and powers down memory;
standbydelayis the delay in seconds between going to sleep and switching to standby mode;
powernapsets whether your Mac will take Power Naps, where supported;
ttyskeepawakecan prevent sleep when a text input, such as a remote login session, is active;
hibernatemodeis set to 0 for plain sleep (desktops), 3 to store a copy of memory to disk and keep memory powered up (laptops), or 25 for full hibernation in which memory is powered down too;
hibernatefilesets the location of the cache to be used when going into standby mode, which must be on the boot disk;
autopoweroffsets whether to go into low-power sleep or standby mode;
autopoweroffdelayis the delay in seconds between going to sleep and going into low-power sleep or standby mode;
lidwakesets a laptop to wake when its lid is opened;
smssets whether to use the Sudden Motion Sensor to park hard disk heads if there is a sudden jolt.
There are a couple of other settings which you can view using
You can inspect current settings using
which here returns:
System-wide power settings:
Currently in use:
Sleep On Power Button 1
If you have a supported uninterruptible power supply (UPS) connected, you can check its settings using
pmset -g ups
which will typically return something like
haltlevel off 0
haltafter on 2
haltremain off 0
The three settings here are:
haltlevel– the % battery level at which to start an emergency shutdown,
haltafter– the time in minutes after switching to UPS power at which to start an emergency shutdown,
haltremain– the remaining time in minutes available on UPS power at which to start an emergency shutdown.
So according to my settings above, when my Mac is running off its UPS battery, it will start making an emergency shutdown after two minutes on that supply. These match the settings you can make in the Energy Saver pane.
Even though you might have your laptop connected to a UPS, portable Macs do not use UPS emergency shutdown settings; in the event of power outage, including the UPS shutting down during a prolonged mains failure, laptops use their internal batteries and follow their own sleep and shutdown settings instead.
You can also schedule automated power on, shutdown, wake, and sleep events, which are detailed in
pmset to change Power Management settings requires you to have elevated privileges, so must be prefaced by
sudo. For example, to set a Mac so that it destroys its FileVault key when going to standy/hibernation mode, you should enter
sudo pmset -a DestroyFVKeyOnStandby 1
then authenticate with your admin password.
When setting values, you will normally need to specify which group of settings are to be affected. This is determined by options:
-bchanges a setting when on battery power (laptops),
-cchanges a setting when on charger (mains) power (laptops),
-uchanges a setting for the UPS, as detailed above,
-achanges a setting for all circumstances (laptops and desktops).
To set the time before a Mac goes to sleep to 20 minutes, you can therefore use the commands
sudo pmset -b sleep 20for a laptop running off its internal battery,
sudo pmset -c sleep 20for a laptop running off its mains charger,
sudo pmset -a sleep 20for any Mac and all circumstances.
If you get the settings into a mess and don’t know what to do,
sudo pmset restoredefaults
should work just like the button to restore defaults in Energy Saver (which you could use instead), and sets everything back to the default settings for that model.
To set a desktop Mac to start emergency shutdown when it has been running on UPS power for 5 minutes, you would use
sudo pmset -u haltafter 5
There are a couple of other useful features in pmset:
will reset the ambient light parameters for those Apple displays which support ambient light adjustments;
can create an ‘assertion’ in OS X / macOS which will prevent sleeping of a particular system. It is fully documented by
Like the Energy Saver pane, settings are stored in a preference file, and acted on through the Power Management system and your Mac’s power management hardware. Until recently (Sierra 10.12.2), settings have been kept in /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist, with scheduled events in /Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist. However, in 10.12.2 the former file has moved back to /Library/Preferences/com.apple.PowerManagement.plist for unknown reasons, and in 10.12.3 the file is now named PowerManagement.[UUID].plist, where [UUID] is replaced by your hardware UUID.
They are also shown in the Power item in System Information (About This Mac, then click on System Report).
You can use
pmset to diagnose odd sleep behaviour in laptops. For example, if your MacBook Pro seems to keep going to sleep suddenly when it has less than 50% of its battery remaining, open a window in Terminal and type
pmset -g pslog
Then when the problem next occurs, wake your Mac and look for sudden falls in the indicated power remaining, such as a drop from 30% to almost nothing. These are typical of an ageing battery which needs to be replaced.
(Updated 23 January 2017 for 10.12.3)