# Useful to prevent Macbooks to go to sleep when closing the lid instead of running tools that requires a Kernel Extension (e.g. InsomniaX) and more | |
# Before doing anything, save your current configuration using | |
pmset -g | |
# To disable sleep | |
sudo pmset -a sleep 0; sudo pmset -a hibernatemode 0; sudo pmset -a disablesleep 1; | |
# And to go back to normal | |
sudo pmset -a sleep 1; sudo pmset -a hibernatemode [original hibernatemode value]; sudo pmset -a disablesleep 0; |
Hey! Do you know how to go back to normal after running the command? Thank You!
Run all the same commands but switch the 1's and 0's like this: sudo pmset -a sleep 1; sudo pmset -a hibernatemode 1; sudo pmset -a disablesleep 0;
Hey! Do you know how to go back to normal after running the command? Thank You!
Run all the same commands but switch the 1's and 0's like this:
sudo pmset -a sleep 1; sudo pmset -a hibernatemode 1; sudo pmset -a disablesleep 0;
This is correct except for hibernatemode
which should be 25 (the defaults, I believe). So the full command should be: sudo pmset -a sleep 1; sudo pmset -a hibernatemode 25; sudo pmset -a disablesleep 0;
. I also updated the gist to reflect that. Thanks for asking how to revert.
be carful sudo pmset -a hibernatemode 25;
should be use for desktop and not macbook. for portable the default is sudo pmset -a hibernatemode 3;
you can check the reference with man pmset
.
true @jujulienarc
I think only sudo pmset -a disablesleep 1
should do the trick.
Howto make this permanent ?
as in?
yes, I am need to make this change permanent. What is the best way ?
Just run the above command once - it will disable sleep permanently. To revert your change just run sudo pmset -a disablesleep 0
again
OK.
I will try it tommorrow morning.
Thanks man !
Ok @kallennp, tell us how it was.
I have some concerns about this, especially the hibernatemode 25 undo command. On my MacBook Pro (Retina, 15-inch, Mid 2015) running macOS Mojave version 10.14.4 with Turn display off after: set to 1 hr, pmset -g returns:
System-wide power settings:
Currently in use:
sleep 60
hibernatemode 3
with no mention of disablesleep. Neither these results, or the output of man pmset, mention disablesleep anywhere, although I have read ( [https://www.reddit.com/r/macbook/comments/alz13m/how_to_entirely_disable_sleep_on_a_macbook/] ) that sudo pmset disablesleep 1 does work, and doesn't need any other parameters, which makes sense since sleep and hibernation are irrelevant if sleep is disabled. (I'm not brave enough to try it, being that I can't see its status in the pmset -g output, even with pmset -g everything).
man pmset shows this for hibernatemode, which makes it look like 25 will be slower than the default setting of 3:
hibernatemode = 0 by default on desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.
hibernatemode = 3 by default on portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from hibernate image.
hibernatemode = 25 is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.
(Sleep can be set to 0 in System Preferences, Energy Saver, Power Adapter, and select Prevent computer from sleeping automatically when the display is off, and optionally deselect Put hard disks to sleep when possible to change disksleep from 10 to 0.)
be carful
sudo pmset -a hibernatemode 25;
should be used for desktop and not MacBook. for portable the default issudo pmset -a hibernatemode 3;
you can check the reference withman pmset
.
The newer MacBook Pro has M.2 fast memory access, so the speed is greatly improved enough to use "25"
hibernatemode 25 is CORRECT, especially for newer MacBook Pro [post-2005]
https://www.lifewire.com/change-mac-sleep-settings-2260804 [check it out]
hibernatemode 25 is not the default. I verified this after Restore to Default in Energy Saver. The article @EveryMac mentioned did not state that 25 was the default—actually, it just can be used on newer laptops (not useable on earlier models):
Note: Since 2005, the default sleep mode for portables has been Safe Sleep, but not all Apple portables support it. Apple says that models from 2005 and later directly support Safe Sleep mode. Some, but not all, earlier versions of Mac hardware include the feature.
Re-reading the article, it is actually a bit vague and confusing about mode 25. This said, the default is definitely not 25. Mine is changed to 25 by a tool recently, and I am very unhappy about the new behaviour. This is partly the reason how I got here.
Hi everyone, I updated the gist. I think it's best to get the current pmset configuration using pmset -g
and use the values from there to go back to normal.
On a MacBook, the default power settings are:
% pmset -g
System-wide power settings:
Currently in use:
lidwake 1
autopoweroff 1
standbydelayhigh 86400
autopoweroffdelay 28800
standbydelaylow 10800
standby 0
proximitywake 1
ttyskeepawake 1
hibernatemode 3
powernap 1
gpuswitch 2
hibernatefile /var/vm/sleepimage
highstandbythreshold 50
womp 1
displaysleep 10
networkoversleep 0
sleep 1
acwake 0
halfdim 1
disksleep 10
Thank you for this. Also wanted to share a setting I use to keep the mac from going into deeper sleep (takes 30 seconds or more to wake up)
sudo pmset -a standbydelay 86400
I am experiencing odd behavior and confused as to if I am looking in the right direction. I have set sleep and hibernatemode off as the gist suggests, yet when I am away from my mac for maybe 30 minutes or so, it seems to still go into some kind of sleep/hibernation/something-else. I also restarted the machine in the case that it might need a reset to respect the new settings. I know this because when I return to it, I receive a dialogue that it was unable to shut down emacs. I am only assuming it has to do with some kind of power-saving mode, but I am baffled as to what. Any ideas? It's rather disruptive as it also kills my tmux sessions. I'd rather just turn all of that off than set up session saving in my tools.
I also have set standbydelay to 86400 as suggested by @dchersey
Hi everyone, I updated the gist. I think it's best to get the current pmset configuration using
pmset -g
and use the values from there to go back to normal.On a MacBook, the default power settings are:
% pmset -g System-wide power settings: Currently in use: lidwake 1 autopoweroff 1 standbydelayhigh 86400 autopoweroffdelay 28800 standbydelaylow 10800 standby 0 proximitywake 1 ttyskeepawake 1 hibernatemode 3 powernap 1 gpuswitch 2 hibernatefile /var/vm/sleepimage highstandbythreshold 50 womp 1 displaysleep 10 networkoversleep 0 sleep 1 acwake 0 halfdim 1 disksleep 10
My default standbydelay settings are way too much.
*
SleepDisabled 1
Currently in use:
standbydelaylow 10800
standby 1
halfdim 1
hibernatefile /var/vm/sleepimage
powernap 0
gpuswitch 2
disksleep 10
standbydelayhigh 86400
sleep 1 (sleep prevented by sharingd)
autopoweroffdelay 259200
hibernatemode 3
autopoweroff 1
ttyskeepawake 1
displaysleep 2
highstandbythreshold 50
acwake 0
lidwake 1
*
You may want to try this
sudo systemsetup -setcomputersleep Never
For other people's reference, I've got a Macbook Pro (16-inch, 2019) that has these default values:
System-wide power settings:
Currently in use:
lidwake 1
standbydelayhigh 86400
standbydelaylow 10800
standby 1
proximitywake 1
ttyskeepawake 1
hibernatemode 3
powernap 0
gpuswitch 2
hibernatefile /var/vm/sleepimage
highstandbythreshold 50
womp 0
displaysleep 10
networkoversleep 0
sleep 1
tcpkeepalive 1
halfdim 1
acwake 0
disksleep 10
Defaults for the mac mini M1
System-wide power settings:
Currently in use:
disksleep 10
powernap 1
womp 1
networkoversleep 0
sleep 1
Sleep On Power Button 1
ttyskeepawake 1
tcpkeepalive 1
autorestart 0
standby 0
displaysleep 10
Is there official documentation anywhere for disablesleep
? I can't seem to find it on the man page or anywhere online.
how to disabled shutdown instead?
Defaults for the mac mini M1
System-wide power settings: Currently in use: disksleep 10 powernap 1 womp 1 networkoversleep 0 sleep 1 Sleep On Power Button 1 ttyskeepawake 1 tcpkeepalive 1 autorestart 0 standby 0 displaysleep 10
Are standbydelaylow, standbydelayhigh, highstandbythreshold no longer usable for M1 macbook?
I was planning to change to hibernatemode 25, but only after 1 hour of sleep on my M1 macbook air.
@ceedveed I have no idea, if you test it, please let us know!
Hey! Do you know how to go back to normal after running the command? Thank You!