Detect If A 2nd Display Is "Online"?

If Mac OS can determine display information:

HP 27es:
Resolution: 1920 x 1080 @ 60 Hz
Pixel Depth: 30-Bit Color (ARGB2101010)
Display Serial Number: xxxxxxxxx
Mirror: Off
Online: Yes
Rotation: Supported
Automatically Adjust Brightness: No

Is there a way for me to do a Pause Until KM can detect my HP 27es in online; AKA: it’s powered up out of “HP display sleep” & getting a signal?

The problem with HP displays, if a display goes into HP sleep, or at reboot any widow that would appear on the HP display at boot up ends up on the main iMac display, because by the time the HP gets a signal, that app or utility already launched & couldn’t find the HP display so it’s placed on the iMac display. And if an HP display goes into Energy Saver sleep it can take 30 seconds or more to power up & get a signal. When it is back up, all windows that were there, are now on the iMac display.

I’ve tried using Pause for 30-60 seconds after Finder launches at boot up, but for whatever reason my macro does not work. If I try the same macro with a keyboard command, it places a window where I want it on the HP display.

So is there a way for me to determine if the HP display is “Online: YES” and or actively getting a signal, then act on that fact with a macro?

Thanks in advance. :blush:

There is probably a Shell Script that can provide the info you want. But, sorry, I don't know what it is. Most likely someone will come also who does know this. Of course you can try searching . . .

However, IMO, this is a problem that should not be happening. Perhaps you can configure the HP display settings to never go into power-saver mode when there is a signal from your Mac.

I have two ASUS 27-in monitors connected to my MBP, and this never happens.
I use the Mac Screen Saver and Power Saver tools in System Preferences to control when/if to put all displays to sleep.

The only thing my ASAU monitors do automatically is to go into power-saver mode when there is no signal from my Mac, like when I put the Mac to Sleep, or power off.
When I wake my Mac, both monitors come alive immediately.

Thanks for the reply.

I’ve been searching for an answer all morning — hence the post here. I’m a Mac consultant … so my 1st inclination is to research & hunt down an answer … and if not … ask.

Sadly, the HP displays are so “PC based” they throw up all kinds of annoying warnings like the No Signal warning that floats around the screen if its Energy saver is turned off, so even if the Mac uses it’s own screen sleep, the HP display goes black, but the waring floats around until there IS a signal coming out of sleep.

The problem I’m trying to solve is more at startup, when the Mac won’t sent a signal to the HP for up to 60 seconds after the Finder “settles down”.

I figured someone out there will have a solution of some sort. I’ll just bide my time, cross my fingers, make sacrifices to the macro godz.:blush:

Maybe you could use the SCREENCOUNT function (KM Wiki).

Thanks! I'll have to explore.

I'm now trying this (screenshot) ... and it seems to be working. But what would be better might be the act on SCREENCOUNT, especially after waking from HP Energy Saver sleep — which is separate from the Macs.

Hey Joe,

Run this from the Applescript, and see what you get when the monitor is asleep and when it’s not.

tell application "Finder"
   set desktopBounds to bounds of window of desktop
end tell

You’ll get a result that looks like this:

{0, 0, 1920, 1200}

AppleScript considers all monitor space as one big desktop, so this should change when more than one monitor is available.

(I only have the built-in monitor on my 17" MacBook Pro right now, so I can’t test myself.)


I got:
Deep Sleep: {0, 0, 2560, 1440}
Not Asleep: {-1920, 0, 2560, 1440}

Hey Joe,

Okay. You can run that from a Execute an AppleScript action as a simple test.

Monitor Status.kmmacros (2.9 KB)



Finally got around to trying this … works great! Thanks! :blush:

Almost 7 years passed and why, oh why I didn't start using KM earlier!?…
So, I'm in a similar situation here, that's why I'm not starting a new topic but, similar, yes. I have a workflow outside of KM to launch some apps and web pages, so my macro needs a "when the app Y is launched" do something. I have a MacBook Pro (M1 if that answers any question) and a 4K DELL display, at home. When at home I want some of these apps, when launched, to move and center on the MBP screen, others to do the same but on the DELL screen. When I'm not at home, of course I'll not be carrying the DELL display, I want these apps that are configure to move and center on the DELL to just center on the MBP screen. What I'm getting right now is that this behaviour is working the right way when at home, when I'm only on the MBP they open and move to the left side of the MBP's screen.
Here is one of these macros.

Macro Screenshot

Move and Center Alacritty on 2nd Display.kmmacros (5.4 KB)

Thanks in advance for any help!