10

Is it possible to prevent OSX from turning off displays when on the lockscreen? I'll lock my MBP with 2 external monitors, leave for 2-3 minutes, and come back and the monitor will be off. It then takes a bit of time for them to all come back on. I've tried Caffeine but it only appears to work when unlocked.

2
  • 1
    What models are your external monitors?
    – Monomeeth
    Commented Sep 30, 2019 at 23:49
  • Dell SE27H & ASUS PB278 each connected through HDMI with a USB-C dongle. The MacBook screen also turns off so it seems not to be monitor related
    – nijave
    Commented Oct 2, 2019 at 13:20

5 Answers 5

5
+25

There is a free and open-source tool named KeepingYouAwake that can be used as per your requirements.

Having KeepingYouAwake activated will prevent the screen from turning off when lock screen mode is activated.

Download the latest version here.

or install it via cask:

brew install keepingyouawake --cask

This utility will not harm your Mac because it is based on an official command-line tool by Apple. BUT I cannot guarantee anything, so use this tool AT YOUR OWN RISK.

1
  • This didn't work for me either
    – nijave
    Commented Oct 17, 2019 at 17:52
2

Settings > Power Management has the options that puts the display to sleep after some time.

It has two independent settings to be used if connected to a power source or using battery only.

Tweak these settings as per your requirement.

3
  • 2
    These don't seem to apply to the lock/login screen. I have mine set to 1hr for both and the Mac still turns the display off minutes after locking (although it works correctly when leaving it unlocked)
    – nijave
    Commented Sep 30, 2019 at 18:28
  • Are you using any screen saver? Commented Sep 30, 2019 at 19:06
  • It's left at the default settings of starting after 20 minutes. It seems to work if I leave it unlocked but I've never seen it start on the lock screen
    – nijave
    Commented Oct 2, 2019 at 13:22
1

Open Terminal and run the following:

caffeinate &

This will keep your display on until caffeinate is killed (you can quit Terminal if you want).

To disable caffeinate, run this in Terminal:

killall caffeinate

Hope this does the trick for you

1

I dug through Console and found it appeared to be checking for preventIdleDisplaySleep boolean. Searching on Github I found HammerSpoon which has a module which can set this via lua scripting. I installed HammerSpoon and added this to ~/.hammerspoon/init.lua and it prevented the sleeping issues

require "hs.caffeinate"
require "hs.hotkey"

hs.caffeinate.set("displayIdle", true, false)
hs.caffeinate.set("systemIdle", true, false)
hs.caffeinate.set("system", true, false)

hs.hotkey.bind({"cmd"}, "l", function()
  hs.caffeinate.fastUserSwitch()
end)

(The hotkey bind to simulate Windows/Linux screen locking behavior)

https://github.com/Hammerspoon/hammerspoon

0

The simplest solution without external software is use caffenaite:

caffeinate -d -w 1

Parameters:

  • -d Create an assertion to prevent the display from sleeping.
  • -w Waits for the process with the specified pid to exit. With pid 1 is waiting for main launchd process, which always exists.

If you do not want to run it manually use lauchd. Create file ~/Library/LaunchAgents/local.caffeinate.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>local.caffeinate</string>
    <key>ProgramArguments</key>
    <array>
        <string>sh</string>
        <string>-c</string>
        <!-- Prevent external display from sleeping. -->
        <string>caffeinate -d -w 1</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

You must log in to answer this question.

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