If you already know the location of the dock, you easily can move a window to the side of the screen allowing for the size of the dock. First lets get some screen data:
This will give you the width of the dock and if you know the dock is on the right side of the screen and you want to move the window far right:
If the dock is on the right and you want to move a window to the left:
If the dock is on the left and you want to move the window to the far left:
If the dock is on the left and you want to move the window to the far right:
zoomalign works with the bottom dock then to move a window to the top or bottom of the screen you would just use
zoomalign in the normal way.
But what if you don’t know where the dock is set at the moment. Here is a sneaky way to get that info from the the dock preference .plist file. That file is a binary file and we need to get the information from the xml version of that file. The unix
plutil command will help us here. We first use a
shellscript command to convert the .plist file to xlm, then load it to a variable and then immediately reconvert it back to binary. Once we have the xml version in a variable we can parse out the location of the dock by checking the “orientation” tag. Having this info we can run whichever of the above lines of code we need. Here is the code to get the dock location:
shellscript ||| plutil -convert xml1 $«x»$|||,y
shellscript ||| plutil -convert binary1 $«x»$|||,y
If you want to move a window to the top or bottom of the screen as well as to either side, you would first use the top or bottom code and then follow with the appropriate side code. Of course the easiest option is to simply wait to see if Apple ever fixes the [NSScreen visibleFrame] problem.