40

Whenever I lock my screen (via either the lock icon -> Lock screen or by using the Control+shift+eject key combination), my screen immediately turns off (not showing the screen saver), and the system seems to sleep. This is inconvenient because it disconnects me from the network, causing Jabber to go offline / ssh connections to die.

I am constantly connected to AC, and am using the following Energy Saver->Power Adapter options:

  • Turn display off after: Never
  • Prevent computer from sleeping automatically when the display is off
  • Wake for Wi-Fi access

I have a 'late 2013' MacBook Pro running OS X 10.9.1.

Is there any way to stop this from happening?

8 Answers 8

39

Had the same problem in my Macbook(15") pro running 10.9.4.

I wanted my Mac to be locked while I was away (so configured hot corners) but at the same time did not want it to sleep (irrespective of whether it is connected to power or not) so that my wifi will be "ON" always for my jabber & mails. So here's what I did to prevent Mac from sleeping:

  1. Open Terminal
  2. Run sudo pmset -a sleep 0

Explanation of the command:

  • pmset command is to manipulate power management settings.

  • -a specifies that the setting applies for all conditions (power & battery)

  • sleep configure system sleep timer

  • 0 to disable

Check out man pmset for more information.

4
  • How to turn it back on? Apr 8, 2018 at 23:02
  • 1
    sudo pmset -a sleep 30 # will configure machine to sleep after 30 minutes May 8, 2018 at 14:59
  • pmset -g will list current settings, but you can't say pmset -g sleep to just show what sleep is set to Jun 28, 2020 at 20:21
  • Mine is already set to sleep 0, and it went to sleep anyway, while plugged in. How do I fix that? Jun 28, 2020 at 20:21
12

I found a solution that works for my needs: As it turns out, I should not lock the screen, but instead start the screensaver, and require the screensaver to immediately require a password.

I created a 'Start Screensaver' service with Automator, and then selected a keyboard shortcut for that service under Settings->Keyboard->Shortcuts->Services.

2
8

The answer is in your post. Just uncheck "Wake for Wifi Access" in the System Preferences under Energy Saver, Power Adapter.

When it's checked, it means that your computer disconnects from the network when you're computer's not awake.

2
  • 3
    Really? Is this documented somewhere? The logic of the phrase "Wake for WiFi Access" suggests just that the checkbox should only affect waking behavior, not sleeping behavior.
    – hobs
    Mar 13, 2019 at 16:08
  • Didn't work for me
    – Alaa M.
    Apr 18 at 9:21
6

Use either caffeinate or something like wimoweh

2
  • 2
    So I need a third party app that prevents the mac from sleeping? I can't just disable 'sleep on lock' somehow?
    – Martin
    Feb 11, 2014 at 14:45
  • 1
    caffeinate is part of the system but it's a command line tool. I don't think there's a preference that will disable sleep completely. I will personally leave my macbook go to sleep and use mosh to circumvent the ssh disconnection problem.
    – huy
    Feb 11, 2014 at 15:36
3

I have a Mac Book Pro running 10.9.5. To keep it from sleeping when I locked the screen, I changed the Energy Saver settings for Power Adapter, I checked "Prevent computer from sleeping automatically when the display is off" and I unchecked "Wake for network access".

2

You can use InsomniaX for that.

With that, you can prevent your mac from sleeping, wether it's idle sleep or even when you close the lid.

2
  • 1
    Please summarize as the link might die in the future.
    – Rob
    Feb 11, 2014 at 14:31
  • +1 the only one with decent settings for everything and it works on El Capitan.
    – unom
    Mar 9, 2016 at 9:16
1

I went to System Preferences > Energy Saver and unchecked Enabled Power Nap while plugged into a power adapter.

0

Install SmartSleep(from Apple Store) with Insomnia plugin and your problem should be solved. You can even play music with your lid closed with no problems.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .