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

Persistent Ids of Screen Change #89

Open mrinvicto opened 2 years ago

mrinvicto commented 2 years ago

I have two identical Samsung Monitors connected to my Macbook pro 14. Everytime the system sleeps the Persistent Ids of the screens change. I tried swapping the persistent Ids and running the script, but then I get the error could not find res:1080x1920x60.

This is really frustrating. Please help out here.

bytejunkie commented 2 years ago

if you run the tool, it'll give you an example command to set to how you currently have it. in that command is the res, which doesnt include the x60 (refresh rate?) you've got in yours. if you look at my example below.

displayplacer list

...

displayplacer "id:0C42AEE1-E7DE-4DF9-BDF2-627294C6E00D res:2560x1440 hz:100 color_depth:8 scaling:off origin:(0,0) degree:0" "id:2B39E8C0-A3BA-42AE-9AEA-45FD00703DFB res:2560x1440 hz:100 color_depth:8 scaling:off origin:(2560,0) degree:0"
mrinvicto commented 2 years ago

Mine is originally like this:

displayplacer "id:37D8832A-2D66-02CA-B9F7-8F30A301B230 res:1512x982 hz:120 color_depth:8 scaling:on origin:(0,0) degree:0" "id:6D6540AF-8F70-4374-B9EE-5D55D76A19E0 res:1920x1080 hz:60 color_depth:8 scaling:on origin:(1512,0) degree:0" "id:CBE61706-1561-4EAE-A447-CE0086904B46 res:1080x1920 hz:60 color_depth:7 scaling:on origin:(3432,0) degree:90"

When I turn on the system after it goes to sleep. The IDs of last two displays swap.

fsmbrad commented 2 years ago

Your Macbook pro 14 is using Apple Silicon M1, right? There seems to be an issue where displayplacer doesn't work on Apple Silicon. See:

https://github.com/jakehilborn/displayplacer/issues/78

I have the same issue with my Mac Studio M1 Max. Currently I don't think there is a solution to this.

colosb01 commented 2 years ago

I have this too. "persistent_screen_id" values are not consistent - sometimes they swap between the monitors after re-docking or waking from sleep.

Displayplacer itself works fine and it can restore screen position for each "persistent_screen_id" (so I interpret I am not suffering from issue #78), but that doesn't help if the ids themselves keep changing over.

In the short-term I will make a cut-down script that I can run manually to simply swap the screens when they are wrong (either as a genuine "detect and swap", or even more simple, just two separate scripts for "ScreenOrder1" and "ScreenOrder2").

But longer term it would be great to have genuinely "persistent" screen IDs, whether to enable displayplacer to work properly, or even better if it would stop the original problem of screen positions being randomly swapped around in the first place.

Machine: MacBook Pro (14-inch, 2021), Apple M1 Pro MacOS: Monterey, v12.5 Display connections: single USB-C/Thunderbolt/DisplayPort cable from MacBookPro to Belkin Thunderbolt 3 express dock HD; HDMI to DisplayPort cable to 1st monitor (Samsung S24E650); USB-C to DisplayPort cable to 2nd monitor (Samsung S24E650) Preferred screen layout: 2 external monitors side-by-side; laptop screen centred below

alxw commented 2 years ago

Here's my workaround to swap position of two displays set to the same resolution (so if you have 3 displays, like a laptop built-in and 2 external, it won't swap an external with the laptop, unless they are set to the same resolution, in which case you will need additional regex customization): Setup:

echo "displayplacer list | tail -n1 | sed 's/displayplacer //;s/id:\(.\{36\}\) res:\([0-9x]\{7,9\}\) \(.*\)id:\(.\{36\}\) res:\2/id:\4 res:\2 \3id:\1 res:\2/g' | xargs displayplacer" > swap_display.sh
chmod +x swap_display.sh

Execution:

./swap_display.sh

Works for me on an M1 Max running macOS 12.5.1 and displayplacer v1.2.0. Best of luck!

Aquenon commented 2 years ago

I seem to be having the same issue with my Mac Studio with 4 displays, but I'm not 100% certain.

The Ultra Wide monitor on top never changes, but the 3 main monitors constantly get out of order after waking. The Display preference pane usually has them listed in the correct order, but if not I can run DisplayPlacer. However, it seems the thunderbolt ports on the rear are what gets out of order.

Using DisplayPlacer does work in the sense that it restores the correct position from the display preference pane perspective, but that doesn't correspond to the physical displays. It's as though while I sleep, gremlins physically unplug my monitors and plug them back in the wrong order. The only way to fix it is to rearrange them in the preference pane and then assign a new main display; or to physically move the thunderbolt cables. Is there any way to assign the thunderbolt ports to a particular monitor ID?

Thanks

colosb01 commented 2 years ago

@Aquenon, out of interest, which type of IDs are you using for your DisplayPlacer settings? - e.g. "persistent_screen_id" or "contextual_screen_id" (I forget if there are also other options).

I initially used "persistent_screen_id", but found that was horribly inconsistent (on my M1 MacBook Pro).

I have since changed to use "contextual_screen_id", and found that is much better; though curiously after OS version update a few weeks ago the displays swapped over and I needed to swap the IDs in my script.

Since then, although the displays frequently swap after waking from sleep, running the script to set locations (by "contextual_screen_id") has always been effective in putting them back where I want.

(I have no deeper insights into the meaning of these IDs or why they might behave differently)

Aquenon commented 2 years ago

Thanks for the quick reply. I had to go back and look. The command just said id, but when I scrolled back up to the DisplayPlacer list command, the IDs are the Persistent screen IDs. Each one has a Contextual screen ID as well, but only the persistent ID is included in the command that the list command generates at the end.

Do I need to edit the generated command to include the contextual_screen_id with the persistent? Or change the command to only use the contextual?

amcclain commented 1 year ago

Do I need to edit the generated command to include the contextual_screen_id with the persistent? Or change the command to only use the contextual?

Looks like the latter option will work - I have the issue described here where the "persistent" IDs can swap between two identical displays on my M1 Mac Studio. You can replace the GUID-style persistent IDs with the contextual IDs in the generated command - for my setup this meant subbing in 3 and 4 for 002EAFBA-FD16-432F-8502-BD9DE188BDD4 and 77456F70-84E6-43E7-9FF9-665D0EBC4281.

I just came across this and made that swap in my little "fix displays" script that runs displayplacer. Now I need to wait and see if those IDs are stickier than the "persistent" ones. (I am not very hopeful.).

Failing that, the approach above from @alxw where the command just swaps the two displays would work well for me - thanks for that!

jakehilborn commented 1 year ago

@mrinvicto @bytejunkie @fsmbrad @colosb01 @Aquenon @amcclain displayplacer v1.4.0 supports addressing screens by serial id. If all of the screens in your setup have unique serial ids, this should fix the id switching issue.

Could you try out the new version and let me know if it works on your setup?

Belilile commented 1 year ago

@mrinvicto @bytejunkie @fsmbrad @colosb01 @Aquenon @amcclain displayplacer v1.4.0 supports addressing screens by serial id. If all of the screens in your setup have unique serial ids, this should fix the id switching issue.

Could you try out the new version and let me know if it works on your setup?

Hey Jake. I've been trying to setup 4 identical projectors as external displays, which I'm having trouble getting to bootup in the correct order (its random every time).

I've tried before and after you released this updated version, but to no avail. Is this something which is just beyond the intended use of Displayplacer, or am I doing something wrong? When I throw my intended 'config (list)' back into terminal, nothing much happens.

Appreciate your work on this greatly!