Hacker News new | ask | show | jobs
by zeroz 779 days ago
After some frustration with shifted windows, usually even after a short break and monitor standby, I tried several solutions. Even tools that promised to save the fixed position were not satisfactory. My preferred go-to solution is now to define sets of window positions in a script for different work situations and simply call them up via keyboard shortcut. No third party tools needed, just works with AppleScript. The nice thing is, that it even works with multiple windows of the same app.

Here an example of my "Dev1" setting with three displays (two 27" external 4K displays and one 14" MacBook). Move Firefox to the first display and leave 50 pixel space for the left side dock. Move IntelliJ IDEA to the second and iTerm2 to the MacBook screen. Works reliable.

  use application "System Events"
  
  get (every window of process "firefox" whose value of attribute "AXMinimized" is false)
  repeat with W in the result
   set position of W to {50, 0}
   set size of W to {1870, 1080}
  end repeat

  get (every window of process "idea" whose value of attribute "AXMinimized" is false)
  repeat with W in the result
   set position of W to {1920, 0}
   set size of W to {1920, 1080}
  end repeat
  
  get (every window of process "iTerm2" whose value of attribute "AXMinimized" is false)
  repeat with W in the result
   set position of W to {1125, 1100}
   set size of W to {1510, 940}
  end repeat
2 comments

I may lose karma for saying this, but the only way I've found to make multi-monitor work is to go to Energy Saver > Prevent automatic sleeping, and then I never turn my Mac Studio off.

Honestly, I've tried a bunch of things, including different monitor setups and apps that intend to put everything back in their place, but none of it was reliable, windows would still get shuffled around. My time is just worth more than the power consumption of an idling Mac. My monitors do get sleep, and even that sometimes rearranges the windows, but it works like 99% of the time. Why is this so hard to get right Apple?

MacOS not ready for the desktop: confirmed

(Yes it's just a satire of people who pick random UX failures like that to say Linux is unusable as a daily driver, as if MacOS and Windows were flawless)