jakehilborn / displayplacer

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

Placement forgotten after restart #100

Open NeighNeighNeigh opened 2 years ago

NeighNeighNeigh commented 2 years ago

When I use Displayplacer to fine tune the placement of my triple display arrangement, it works great! that is until I restart the computer, where the placement is now lost. Is there any way to bake the adjustment into the system preferences?

Displayplacer version: v1.2.0 macOS version: 12.5.1

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!

NeighNeighNeigh commented 2 years ago

Oh okay, so my problem is that when I restart the computer my left display is now -127 on the Y instead of -200. My right display is -150 instead of -200. These seem to be the values from when I set them manually in display preferences. So after every reboot I need to use displayplacer to make them both be -200 on Y. What I’m wondering about is why this isn’t remembered between restarts?

alxw commented 2 years ago

I don't know if it's possible to put this into the system preferences, and I have no idea why that's happening.

displayplacer lets you set things how you like, and then "export" the setting using displayplacer list (which you'll need to save somewhere so that you can later execute it). displayplacer does not automatically apply the setting, but it gives you the ability to set it via command-line, which I believe you can set to run upon log-in using Automator.

However, displayplacer can get the display ids mixed up even still (if you have two identical displays), especially on M1, so my workaround above can address that. (For me, it's a 50% chance they get mixed up every time the displays go to sleep). Perhaps this wasn't relevant to your issue, I just thought my fix might have a chance at helping you.

NeighNeighNeigh commented 2 years ago

Ah thanks that's a good idea, I just set up an automator application to run at startup. Still, it seems weird that changes made by display placer are not persistent between restarts. So far I haven't had a confused id's situation as yet, so fingers crossed it stays that way.

jleatham commented 2 years ago

My displays mix up randomly after sleep or after undock/docking . I set up the displayplacer list command as an automator workflow service and it works sometimes and othertimes it still gets switched up.

So I took @alxw 's script and put it into another workflow: /opt/homebrew/bin/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 /opt/homebrew/bin/displayplacer

So now I have two shortcut commands, and between the two, so far, I can get the displays correct. Technically, the swap workflow throws an error, but the command works, so it still saves a ton of time.

mgumz commented 2 years ago

@NeighNeighNeigh i would argue that osx is forgetting the monitor settings. displayplacer is doing what you would otherwise do via the settings-pane, there is essentially no difference. why osx is doing something interesting after the reboot is beyond me … but i can't really see a way on how displayplacer could "fix" this.

alxw commented 2 years ago

@jleatham I think this might solve the workflow error - LMK:

/opt/homebrew/bin/displayplacer list | tail -n1 | sed 's/displayplacer //;s/id:\(.\{36\}\) res:\([0-9x]\{7,9\}\) hz.*color_depth:. \(.*\)id:\(.\{36\}\) res:\2 hz.*color_depth:.\(.*\)/id:\4 res:\2 \3id:\1 res:\2\5/g' | xargs /opt/homebrew/bin/displayplacer
ahaverty commented 1 year ago

Apologies if this isn't relevant, but in my case I was just losing the resolution and my script was failing due to differing ID's (I have a second user account, perhaps that's messing with things?)

I've hardcoded the above suggestions, with a specific resolution for both of my matching screen. Script in case it's useful for anyone else:

/opt/homebrew/bin/displayplacer list | tail -n1 | sed 's/displayplacer //;s/\(id:[0-9A-F-]* \)res:[0-9]*x[0-9]*/\1res:3008x1692/g' | xargs /opt/homebrew/bin/displayplacer
jakehilborn commented 1 year ago

@NeighNeighNeigh @alxw @jleatham @mgumz @ahaverty 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?

jleatham commented 1 year ago

Did not work. My 2x External monitors are the same brand/size and received the same serial number of: s1 . Noticed the screens continued to switch on me and the new 1.4 command did not fix it.

Thank you for continuing to try! Similar error as before: The action “Run Shell Script” encountered an error: “Screen ID 89EFF074-2134-424F-9523-F152889F353C: could not find res:2560x1440 hz:75 color_depth:8 scaling:off Screen ID 47EB9DEA-706C-4888-9D15-DBB30001CFC7: could not find res:2560x1440 hz:144 color_depth:8 scaling:off”

On Sun, Jun 11, 2023 at 4:12 PM Jake Hilborn @.***> wrote:

@NeighNeighNeigh https://github.com/NeighNeighNeigh @alxw https://github.com/alxw @jleatham https://github.com/jleatham @mgumz https://github.com/mgumz @ahaverty https://github.com/ahaverty displayplacer v1.4.0 https://github.com/jakehilborn/displayplacer/releases 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?

— Reply to this email directly, view it on GitHub https://github.com/jakehilborn/displayplacer/issues/100#issuecomment-1586338241, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARW2ZEGRFEXGL3KBBYAX2LXKYYE3ANCNFSM6AAAAAAQFPAV4U . You are receiving this because you were mentioned.Message ID: @.***>