Here's the scenario:

In my office, my MacBook Pro (Early 2011, running 10.10) is plugged into an external display over DisplayPort. I disconnect the laptop, close it (putting it to sleep), and take it with me. When I arrive to my destination I find that opening the laptop wakes it up to a black screen– however it is awake:

  • Backlight is visibly on
  • Volume controls work (I can hear it, no visuals)

The simplest way to solve this is to either restart or go back and plug it in to a monitor and retry the sequence of disconnecting to ensure this doesn't happen. Neither of these are feasible at the moment for various reasons. Session details:

  • Multiple users are logged in
  • Assume that some files are not saved or that progress may be lost by restarting (I think I'm safe here, but it's good for the exercise)
  • All users have a password protected lock screen upon awakening (though I am aware of the current user and password)
  • I have access to the shell which can be confirmed by opening iTerm (via shortcut) and entering "say hello"

Some of the suggestions I've seen for resolving this without a restart involve "Detect Displays" but unfortunately that's a bit too difficult to get to in the GUI without any visual feedback. All that being said, are there any creative ways to escape this using either the command line, AppleScript, or even guess-and-click if completely necessary?

1 Answer 1


I found this on Stack Overflow, to invoke 'Detect Displays' - which you could include in an Automator Service & then give a key command.

Of course… it would only be good for next time it happened, not this.

tell application "System Preferences"
    reveal pane "com.apple.preference.displays"
end tell

delay 0.5

tell application "System Events"
    tell process "System Preferences"
        try --don't even consider not using a try block!
            key down option
            delay 0.2
            click button "Detect Displays" of window 1
            delay 0.2
            key up option
        on error --logging out is the only other way to clear these
            key up option
        end try
    end tell
end tell
  • 1
    I came across this answer as well but as it turns out Script Editor needs assistive access for this to work, which unfortunately was not enabled. [Note: This is the case if you try running it through osascript as well.] I've since enabled it so if I manage to replicate the situation again I will give this a try. One concern with this method is that "Detect Displays" may not be available on all systems (I saw some reports of it not appearing even with the option key held) or when the external display is the primary one as in my case.
    – ics
    Oct 23, 2015 at 15:05
  • Is there any way to run this, if your display normally locks and you haven't enabled SSH? I've been suffering this problem - at work! - about twice a month for 4 years, on two different laptops and many OS upgrades. I feel like I need a second laptop just for meetings, or I need to go back to Linux. Nov 29, 2017 at 19:17

You must log in to answer this question.

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