Depending on what you are trying to do, there are a number of things you might do. Here are a few disjointed thoughts…
- If you are looking to accomplish everything in KM, there are some built in actions that position windows, as well as the ability to specify the exact window coordinates and size. These actions, as far as I can tell, are most usefully applied to the front window.
When doing this in KM, a problem is that as far as I have discovered so far, there is no way to easily determine what of multiple attached screens a given window is on. KM numbers the screens from 1 to N, with 0 being the “main” screen, and one of the numbers 1…N will also be that same main screen. It is not easy to figure out which screen number goes to which attached screen, however.
What I have done is to write a number of utility macros. One figures out which screen the front window is on. It does this by getting the coordinates of the top left corner of the window and then scanning all attached screens to see which screen’s bounds contain that corner.
I also have another macro that positions a window on a specified screen. It allows you to specify the desired screen (numbered 1…N), a grid pattern for the screen (rows and columns), the row/column for the top left of the window, and the number of rows and columns the window spans.
Using this macro I can easily put a window in the top left corner, top third, left third, etc, as desired.
I then have a palette of macros that use these utility macros to position windows, as well as macros that will open a set of apps and position their front windows. For example, on my desktop, a macro that is run every few minutes makes sure that my left hand monitor (of three) has OmniFocus full height left 1/3, Mail full height right 2/3, and my rightmost monitor has Messages in the top right corner and Calendar in the bottom right corner.
Obviously this macro is only useful on my Desktop with three monitors. One problem is that there is no way to figure out the screen number of the left, middle, or right monitors other than empirically, so if I were to rearrange the connections to my Mac Studio this macro would have to be changed.
-
Better touch tool also has window positioning actions, including preset actions such as left 1/3, top 1/2 etc, plus a custom positioning / sizing action and options to move between screens. I presently have a bunch of keyboard shortcuts for some of these actions that I use the most, and also a pop-up menu for less used window positions. Thus, I use a mix of BTT and KM for different positioning purposes.
-
There are special purpose apps, like the ones already mentioned (Moom, Rectangle, etc) that are in general very good, and I know you can trigger a recorded window position layout in Moom via AppleScript and hence from KM. I played with Moom, but it did not meet my needs primarily because I wanted to have a way of having some windows take up thirds, some quarters, some halves, etc, and with Moom as far as I can tell you can have only one grid specified that applies to all layouts, but my KM macros let me use any grid layout I want for any given macro, so I needed some KM-fu to get what I wanted.
I should perhaps note that I also have these KM macros assigned to a layout on my StreamDeck…
Now, I know I have done nothing to address your question - how to make these things work differently on laptop vs desktop.
Two obvious solutions in KM:
- If your desktop has >1 screen but your laptop is only used with the built-in display (or in general your desktop has a different number of screens than your laptop) the you can code your window macros in KM to check the number of screens and execute different actions depending on the screen count;
- You could create two macro groups of window positioning actions, one for each computer. Because macro groups can be disabled on a per-computer basis, just disable the one you don’t need on each computer.
Right now BTT has syncing between computers only on an experimental basis, so for now you would create actions separately on each computer which also would work for you, but once they have syncing working (and I do intend to use it), hopefully they will have a way to designate some actions as restricted to one computer or the other.
Lots of ramblings. I hope some of this helps.