Adjust Monitors Programmatically (Or at Least Prevent OSX From Confusing Them)

I currently am using a new Silicon Macbook Pro with two Trio Max monitors. One is set up vertically and on horizontally. Unfortunately, OSX seems to not be able to distinguish the monitors. So every single time that my computer wakes from sleep, there is a 50% chance it will confuse the two and apply rotation to the wrong one and swap their locations. It's so annoying that it makes me want to never sleep my computer which is obviously an ugly workaround.

I have posted about it on slack and haven't yet got a solution there. Someone else asked a similar question on the apple forums and got no responses before me. There I learned of displayplacer, but that apparently doesn't work on silicon macs.

I know this might not be directly KM-related, but whenever I have Mac issues like this I tend to think of this community since you're all creative problem solvers. Or maybe someone has even made a KM macro related to these issues in the past?

Yikes. :face_with_open_eyes_and_hand_over_mouth:

A few days ago, for a slightly different problem, I pointed out that monitors don't (seem to) have a unique ID. I'd like you to to open "About This Mac" from the Apple Icon, then click on System report, then navigate to Graphics/Displays. Look at the details of your two monitors there. (Maybe post a screenshot of them.) I think we need to look in there to see if there's some unique ID for each monitor. If there's some unique ID, then maybe I can figure out a way to help here. I emphasize "maybe."

I also want to ask you how they are connected to your laptop. Do the cables go through a hub/dock, or do you connect them directly to two USB ports on your laptop. It could be that a hub is camouflaging the unique IDs.

These are just ideas I have. I'm kinda expecting to fail here.

But actually I have another idea if these ideas don't bear fruit. but it would cost $50, so I won't mention it yet.

Thanks for your response @Sleepy. The screenshot is attached. Each is attached with a two-way USB-c connection to a separate USB-C hub. I'm very interested to hear your ideas, even the expensive one.

If you are correct that they don't have unique IDs (which is what I guessed might be the case) then I agree there might be very little we can do :confused:

Well, actually, as far as unique IDs go, I haven't exhausted that idea yet. You can see in the screen shot that they both have different values for "Resolution." I was wondering if that swaps monitors when the Rotation values are swapped. If they don't swap, then we have the basis for a trigger that might fix the problem, because we could have KM detect this condition upon system wake. However we haven't even discussed yet whether there is a way to fix this problem through code once you've detected that it happened. If you can't figure out a way to perform a swap via software, then detecting the wrong swap isn't of much use.

But let me mention my $50 solution. (Probably closer to $30). If you can get the monitors to power up in a specific order during system wake, then that MIGHT fix the solution. My idea is to use a $30 smart power switch that could force one monitor to not wake up before the other one. It's just a hunch, but I'm hunching that the random sequence you are experiencing depends upon which monitor gets power first. And by enforcing the order with a smart power switch, we might be able to solve the problem. Before you go out and buy one, just try pulling out/in the power cable for one of the monitors before and after a system sleep. If doing this manually solves the problem, then I think we can solve it automatically with a single smart power switch for $30.

Despite the fact that each of the above paragraphs may lead to a solution, there might be a "right" way to do it. You said that there are some software products that are good with manipulating monitors. They might have access to some API that is either undocumented or not widely known. Searching for such products may be a third option you still have.

I'm not any sort of hardware wizard. I'm just doing my best to give ideas. If my ideas are flawed, I apologize.

Well, have you tried plugging the monitors directly into the MacBook instead of using a hub? Doesn't your MacBook have two USB-C ports? I'm not trying to get you to solve the problem this way, I'm just looking for clues.

Sorry, I misused the word "hub". I actually meant "port". They are connected directly to my mac.

I like this idea! Can you recommend one? But just to make sure we are on the same page, I should clarify that these monitors are not powered by anything except the usb-c connection. There is no separate power cable. Is the device you are thinking of for usb-c connections?

Even though it may cost $30, this would make me feel comfortable letting my computer automatically go to sleep after a short period of inactivity (whereas for now I've turned off auto-sleep). So I think it would actually save me money in the end if you factor in that I'll extend the lifespan of my device by letting it sleep more.

Based on the search I've done so far, the only one I came up with is displayplacer. And according to a github issue I linked on top, this won't work yet on silicon macs.

I never knew that was possible (monitors getting power from a USB port)! Well then, I have to reconsider. Let me think about it while I eat my lunch.

I'm no expert on smart power outlets, but the one I have is a Wemo and it works well. See image below. I use it for a similar purpose, because I'm using it to get Siri to turn it on by voice command. Apparently my Apple TV won't power up the monitor when I power up the Apple TV by voice. These things aren't very expensive. I recommend anyone who has HomeKit devices get at least one to experiment with it.

I'm still pondering your problem. I'm not out of ideas quite yet.

Since you are familiar with github, I guess I can refer you to this GitHub code: uhubctl

Apparently it lets you power up or down specific USB ports. I'm hoping that if you get that utility you can power down each monitor individually. And you can also power them up individually. I'm hoping that this will change the order that they boot in a way that can solve your problem. You probably need to use this utility to shut them both down, then start them back up. I can't really test this for you; you are on your own here.

I'm curious: do the displays also switch position in the "Displays" settings pane? or switch places in coordinate space?

Excellent question.

They swap places in the coordinate space, and the rotation settings are swapped. I can't distinguish them in the Displays settings pane. They are given the names "(1)" and "(2)", but it seems random. Or hopefully, it's according to the order they are detected.

Screen Shot 2022-02-18 at 6.14.45 PM

Wow, what an idea. I will see if I can work with this and let you know...

Hehe, thanks. It sounds like it may work. 50-50 chance.

Another thing to try (and this is an ugly hack): you could try to power off one of the displays until the other had been recognized. ?

Did you see that these monitors don't have power cables? They are just powered from the USB port.

EDIT OOPS. I thought you meant with the power cable. You probably meant with a power button. I'm not sure if all USB-powered monitors have power buttons. But that would absolutely be a valid test, and it's a good idea, but he wants to do it programmatically.

FYI, I use displayplacer daily on M1 Max (Monterey) and it works very smoothly. I am unsure if it's officially deprecated but still running strong.

I switch daily between three different multiple monitor set-ups. So I've got a macro which detects the set, and applies my saved setting. Saves me 1 minute per day, but somehow is my favourite macro.

There have been rumors about Apple's Tuesday announcement (only a day away now) that there will be new monitors from Apple. And since some of the rumors include "Ax series" processors inside the display, that could result in an impact to KM. For example, the new monitors might have an API to allow support for KVM functionality. Hopefully KM will be upgraded if there's any new APIs.

@Matthew16 FYI SwitchResX seems to be able to achieve what you are looking for, on M1. Paid application though!

https://www.madrau.com

No KVM functionality. So I won't get one until I really need one.