jakehilborn / displayplacer

macOS command line utility to configure multi-display resolutions and arrangements. Essentially XRandR for macOS.
MIT License
3.74k stars 134 forks source link

Broken on M1 due to deprecation by Apple #103

Closed gingerbeardman closed 1 year ago

gingerbeardman commented 1 year ago

You can build M1 version:

  1. download zip of this repo https://github.com/jakehilborn/displayplacer/archive/refs/heads/master.zip
  2. cd displayplacer-master
  3. make
  4. ignore the warning

BUT, it's still broken with a different error at runtime.

When I try to rotate my external display:

(ipc/send) invalid destination port, code: 0x10000003

Though listing and changing resolution of internal display still works OK.

It seems Apple has truly discontinued some technology that this and other similar apps rely on.

mgumz commented 1 year ago
$> sysctl -n machdep.cpu.brand_string
Apple M1 Pro

$> sysctl kern.osrelease
kern.osrelease: 22.1.0

$> ./displayplacer list
...
displayplacer "id:9C69CCDE-5CC0-45A9-BC66-6C92930D2A1B res:2560x1440 hz:70 color_depth:8 enabled:true scaling:off origin:(0,0) degree:0" "id:14366830-F2AC-437E-8016-102718134C0E res:2560x1440 hz:70 color_depth:8 enabled:true scaling:off origin:(-2560,0) degree:0"

I do not understand your issue at the moment. On my M1-Pro + Ventura, displayplacer works.

gingerbeardman commented 1 year ago

I do not understand your issue at the moment. On my M1-Pro + Ventura, displayplacer works.

Sure, I can list the display properties no problem.

But I can't set rotation or resolution of my external display. Can you @mgumz?

mgumz commented 1 year ago

@gingerbeardman it doesn't matter so much what I can do or what I can't: your issue description is lacking what you can't do.

gingerbeardman commented 1 year ago

Fair, I've added that info.

So let me ask again: I can't rotate my external display, can you?

lejacobroy commented 1 year ago

I'm using a M1 Pro Macbook Pro and while displayplacer works to list the config, it cannot apply it when my external displays are out of order. No errors are given on terminal, and not change is made. Here's the command: /opt/homebrew/bin/displayplacer "id:37D8832A-2D66-02CA-B9F7-8F30A301B230 res:1512x982 hz:120 color_depth:8 scaling:on origin:(0,0) degree:0" "id:382DB9ED-880B-4CBE-BA09-93FA2E8558D7 res:1920x1080 hz:75 color_depth:8 scaling:off origin:(1512,-98) degree:0" "id:6297311A-1D4F-48F8-9361-537D0D23A54C res:1920x1080 hz:75 color_depth:8 scaling:off origin:(-1920,-98) degree:0"

gingerbeardman commented 1 year ago

it cannot apply it when my external displays are out of order.

What do you mean by "out of order" here?

Does it work with external displays are "in order"?

lejacobroy commented 1 year ago

My physical display setup is as follow : [external 1] - [internal] - [external 2]

In system preferences, I arrange the logical setup in the same order, then run displayplacer list

If my mac goes to sleep or if I unplug & replug the monitors they will get randomly in the same order or logicaly out of order ([external 2] - [internal] - [external 1]) and so if i move my cursor passed the right side of my internal screen, it appears on the left side of my left monitor instead of the one on the right.

At this point if I try to run displayplacer using the previously generated list, the logical screens are not re-aligned with their physical monitor.

Hope it all makes sense

varenc commented 1 year ago

Saw this issue and figured I'd jump in!

@lejacobroy Just to confirm, when you re-plug in your monitors after waking from sleep does macOS itself randomly reorder your screens? I think that's the root of the problem since macOS should be restoring your last arrangement by default. If macOS itself is confused then I bet displayplacer's "persistent ids" are also getting confused since they're just generated from macOS APIs.

You can check this by seeing if displayplacer's persistent ids actually persist and refer to the same monitor after macOS has randomly re-arranged the displays. You change just one monitor's setting by passing in only that monitor's settings to displayplacer, as in, only displayplacer "id:<persistent id> res:<new_resolution> ....". Then do another re-plug/wake cycle, confirm that macOS has re-ordered them incorrectly, and run a displayplacer command again on the same persistent id. If that persistent id now effects another physical monitor you know that the displayplacer's persistent ids are changing too.

If the persistent ids are changing then you're probably out of luck since the problem is just in the macOS APIs that displayplacer relies on. Though you could try using the 'Contextual screen ids' instead of the persistent ones, but I'm doubtful. Look for 'Contextual screen id:' in the full displayplacer list output and swap each screen's persistent id for the contextual id in your command.

Also out of curiosity, are your 2 external screens identical models/brands? There's reports saying that can cause this bad behavior.

lejacobroy commented 1 year ago

Thanks for the good reply @varenc , I will test all those points tomorrow when I'm back at the office.

Yes, it's macOS that randomly reorder my screens and that's why I wanted to use displayplacer, to correct this behaviour. Both screens are the same brand & model, I guess that's why macOS is confused.

I'll definitely try the 'Contextual screen ids', thanks for the suggestion.

If displayplacer is not the right tool, do you know any tools that can "fix" the screens to physical displays?

gingerbeardman commented 1 year ago

@lejacobroy Have you organised the screens by drag and drop in the Displays > Arrangement panel?

You might be able to adjust order by dragging the menu bar from screen to screen (signifying main screen) and see if that helps?

image

lejacobroy commented 1 year ago

@gingerbeardman Yes, during the initial setup (before I do displayplacer list) I'm arranging the displays in the Arrangement panel (it changed a bit in Ventura, but same same). My middle display is the main screen (with menubar and dock) and is the MacBook Pro one.

gingerbeardman commented 1 year ago

@lejacobroy interesting, quite likely an Apple bug.

Can you physically change the order of your screens? By swapping the outputs/cables to your displays? What happens in this instance?

lejacobroy commented 1 year ago

@gingerbeardman It seems to be the normal behaviour (as in a well known bug ;) ), from what I read online. I can physically change the order of the cables and change their side, but it has no difference.

gingerbeardman commented 1 year ago

Changing the cables does not swap the display order!?

lejacobroy commented 1 year ago

@gingerbeardman sorry, it kinda does. The problem is that the initial ordering by macOS (be it from pluging the cables in a certain order or waking from sleep) is 50% of the time in the good order (physical ordering match logical ordering) and 50% of the time the ordering of the external monitors are swapped. Even if I change the cables order, the outcome is the same, even if the initial ordering is reversed.

Using displayplacer with the contextual screen ids managed to reorder the screens after a sleeping test, but the app windows were still swapped (which I guess there's no fix?)

lejacobroy commented 1 year ago

@gingerbeardman @varenc Since my problem with displayplacer is fixed by using contextual ids, I wanted to thank you for your help and your time! Sorry that I highjacked your thread about a compiling issue!

gingerbeardman commented 1 year ago

My error is at runtime, but glad you got your setup working!

alissoneloi commented 1 year ago

I've tried every way possible, it just doesn't work on the M1 and M2 processors;

jakehilborn commented 1 year ago

@gingerbeardman @mgumz @lejacobroy @alissoneloi M1/M2 rotation has been fixed in release v.1.3.0. Could you try it out and let me know if it works?

The issue with contextual/persistent screenIds switching around still exists due to deep macOS bugs. I'll try to get to the serial ID workaround soon, but that's still prone to issues with manufacturers reusing serial IDs.

mgumz commented 1 year ago

@jakehilborn yep, displayplacer:v1.3.0 works on my m1-setup with mirror/unmirror. thanks for the release btw.

gingerbeardman commented 1 year ago

latest works for me!

(make sure you check you don't have any old versions hanging around)