How to determine the main screen


I use a MacBook and have dual monitors, both at home and at work. The problem is that at home the icons are on the right screen and at work on the left screen.
Is there a way to determine which is the main and which is the second screen based on the position of icons? I would like to use it as a variable and based on that determine whether the left screen is main or vice versa as I would like to position (move and resize) windows based on right/left and not on main/second screen.


Hey @andrej,

Run this from the Applescript Editor on both systems, and I believe you'll find the position is different.

tell application "Finder"
   set bootDiskPosition to desktop position of disk "Mercury"
end tell

(I only have one screen, so I can't test...)

If that works then you can use something like this to get the info into Keyboard Maestro:

Locate Position of Boot Disk.kmmacros (4.6 KB)


Actually, KM can directly address the "main" screen, and any other screen, as in:
SCREEN(main, top)

See SCREEN function.

You can get the frame coordinates of any screen using the %Screen% token.
So for example, %ScreenVisible%Main% gives the visible frame of the main screen.
See Screen token.