3

I have 3 displays, MacBook and 2x4k. My main display is one of 4k. The issue is when I lock computer often 2nd 4k Display (not main) move all full screen apps to MacBook, MacBook to this 4k. Only main display have apps on place. To solve this issue I have to open preferences/ display/ arrangement and move white bar from main display to MacBook, than "not main 4k" and to "main" 4k. In conclusion I have to move white bar 3 times. This is really uncomfortable and I wonder how to do it wit apple script. Right now I find solution to open system preferences-> display -> arrangement, however I have no idea how to move white bar around displays. My code is here:

-- QUIT SYSTEM PREFERENCCES APPLICATION
if application "System Preferences" is running then
    tell application "System Preferences" to quit
    delay 1
end if
tell application "System Preferences"
    activate
    set the current pane to pane id "com.apple.preference.displays"
    delay 1
    tell application "System Events"
        click radio button "Rozmieszczenie" of tab group 1 of window "LG Ultra HD (1)" of application process "System Preferences"
    end tell
end tell

Can anyone help me how to finish script?

Thank you!

3
  • 1
    Have a look at my answer, A: Script to relocate the menu-bar on dual monitors set-up, which is written for two displays; however, I do not readily see why it couldn't be used for three. You'll just have to gather the information for the three displays and run the cscreen commnd appropriately to achieve the goal. Commented Mar 26, 2019 at 16:04
  • @user3439894 cscreen can do what I need, however unfortunately also it change screen location :( so right now I have 4k-non main ; 4k main ; MacBook. After switching 3 times cscreen to change apps on displays my arrangement is: MacBook ; 4k main display ; 4k non main display. so it not only move apps around, but also move whole display location. Mouse cannot move smoothly via all displays :/ Commented Mar 27, 2019 at 7:27
  • When I run it second time to switch back localization of my screens is: MacBook, main 4k, non main 4k Commented Mar 27, 2019 at 7:33

1 Answer 1

4

I wrote a command line tool called displayplacer that will help with this. You can specify the resolution and positioning of your various monitor setups. Setting a screen with origin:(0,0) will make it the main display with the white bar in the settings.

Execute displayplacer list to get your screen ids.

Example profile 1 with MacBook screen displayplacer "id:<4kScreen1> res:3840x2160 scaling:off origin:(0,0) degree:0" "id:<4kScreen2> res:3840x2160 scaling:off origin:(-3840,0) degree:0" "id:<MacBook> res:1440x900 scaling:on origin:(3840,0) degree:0"

Example profile 2 without MacBook Screen displayplacer "id:<4kScreen1> res:3840x2160 scaling:off origin:(0,0) degree:0" "id:<4kScreen2> res:3840x2160 scaling:off origin:(-3840,0) degree:0"

Also available via Homebrew brew tap jakehilborn/jakehilborn && brew install displayplacer

1
  • I have a problem with my system, perhaps with one of my monitors or my docking station, where the monitors sometimes wake up in random resolutions or rotations. Thanks for this solution that will hopefully make it very easy for me to fix this every time it happens. I tried doing it with Applescript but ended up in various black holes of undocumented secrets. This makes it easy.
    – jay613
    Commented Dec 9, 2021 at 12:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .