Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manipulate OS X windows with script

Tags:

Ok, so I'm trying to make my setup super simple by creating a script that I can run in the morning that will launch all the applications that I use in the day and lay them out across my 'spaces' how I like them.

This was going ok and I was easily able to have a bash script launch the apps and then call to an AppleScript to move and resize their windows.

However, I like to use the new El Capitan feature and have some of my spaces as 'split view' spaces. E.g. Full screen Xcode/Terminal split. I can't seem to find a way to control this via a script.

Tl;dr Does anyone know how to get a bash script/AppleScript to put two applications into 'split view' on OS X El Capitan?

like image 412
George Green Avatar asked Jun 14 '16 08:06

George Green


1 Answers

Looks like that first bit about launching and full-screening apps can be done with a fairly simple script, though it requires enabling Accessibility permissions first. It, however, won't do the split-screen bit.

I kept looking though and Better Touch Tool (pay what you want, $4.49 minimum) seems to get the closest of anything I could find, allowing you to trigger Full Screen mode and bring up the split screen Expose selector in the same action. It seems to be doing this by emulating a long mouse down on the full screen window control button (the green one in the top left). What you get is this:

Safari entering Full Screen mode with spilt-screen Expose view

I've been playing around with this and it seems there might be a (so far seemingly very un-intgelligeble, though reliable) way to control the order of full screen apps and trigger an app into split screen mode in a situation where that previously full-screened app is the only option available for splitting the screen.

For example, given the following, accomplished by launching iA Writer into full screen (space 2) via +^+F:

enter image description here

Focusing Safari and using Better Touch Tool to trigger split screen mode results in:

enter image description here

... Only one split screen app, even though there's several apps still running.

From this position you could use the "move to position" action in BTT and trigger a click on the only available app— I would think this could theoretically accomplish what you want, although it's convoluted and a bit suspect.

All that being said, it seems like the only way to get two apps launched into split screen mode without touching the mouse, since this could all be a BTT workflow you trigger from an Automator script. Digging further, you might be able to learn how BTT accomplishes their actions and write a program that does this for you, but we're already way beyond bash or simple cli scripting.

I personally just use Spectacle and tmux to zoom my windows around, though I admit, automated split screen would be somewhere close to live changing.

like image 189
justin Avatar answered Oct 04 '22 14:10

justin