44

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?

Martin
  • 661

8 Answers8

42

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.

Jens Erat
  • 2,026
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.

Martin
  • 661
  • 1
    Could you post your Automator script? – hobs Mar 13 '19 at 16:08
  • Unfortunately I no longer have the script, but this might help: https://apple.stackexchange.com/questions/135728/using-applescript-to-lock-screen – Martin Mar 20 '19 at 10:29
9

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.

Joe
  • 99
  • 4
    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 '19 at 16:08
  • Didn't work for me – Alaa M. Apr 18 '22 at 09:21
6

Use either caffeinate or something like wimoweh

huy
  • 306
  • 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 '14 at 14:45
  • 2
    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 '14 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.

narrowtux
  • 141
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.