Yak-Shaving with Slate

22:36 Sun 04 Aug 2013
[, , , , , , ]

Slate is a window management tool for OS X that I’ve been playing with recently. It’s open source, it has JavaScript bindings, and it’s extremely useful if, like me, you’re particular about setting up your digital workspace.

However, in part due to restrictions in OS X, it’s not as useful as it could be. I had intended to write a post about how I’d made it do a variety of nice things, but that will have to wait until next week.

What I want to do with Slate isn’t that different from what people often like to do with “virtual desktops”, i.e. sets of windows that each look as if they are the only set of windows you’ve got open. I tried that with OS X’s built-in Spaces tool a while back, but it just required too much work. You couldn’t hit a key and have your applications and windows set up the way you wanted, but had to manage them more manually than that.

I still find myself wanting something similar, though, and recently coming into more screen space reminded me of it.

An example is how I’d like to have my windows arranged while writing my blog post—and with a combination of Slate, JavaScript, and some trickery I’ve managed to make it do some of what I want. But not all, and I had to manually make some of this happen as well:

Left Screen
Top Half
iTerm, running tmux, with a tmux session/window/pane for doing any necessary command-line work (most likely version control commands).

Bottom Half
A browser (Chrome) to do research typical for writing blog posts, i.e. surfing the web.

Middle Screen
Left Half
A MacVim window dedicated to blogging.

Right Half
Another Chrome instance, this one displaying the local preview of the blog post.

Right Screen
Upper-Left Quadrant
The VLC player with whatever music I want to listen to while blogging.

On top of that, I want everything else to be hidden.

That’s not a spectacularly elaborate setup. But it’s unfortunately more difficult than it sounds.

A key problem is the combination of wanting dedicated windows from some of the applications and my tendency to have multiple windows running for each application. Despite efforts to cut down on the tabs I leave open, I tend to have at least two Chrome windows, each with a lot of tabs, open most of the time. I don’t want to have to close those when I start writing a post—I just want them to be hidden, and for Chrome windows with the blog-related content to be in the correct positions.

Sadly, OS X doesn’t expose any simple way to tell those windows apart, and Slate addresses each application by its name. That’s where some of the trickery comes in—but I’ll leave the details for a later post, hopefully next week’s. By forcing Chrome to run as separate instances, and then being tricky, I was able to make Slate understand the difference between the Chrome for general browsing, the Chrome for previewing the post, and the Chrome for blog-related research.

Getting to that point made me hopeful about the rest, so I moved on to MacVim… where progress halted. For undoubtedly good reasons that are unknown to me, MacVim won’t let you launch multiple instances—and if it does, the first instance takes control of their windows. So I couldn’t run multiple instances, at least not without actually copying the MacVim application files on disk and applying Seth’s tricks to the copies, something I was trying to avoid. I hope there’s some way around this, but I haven’t found it yet.

What this ends up meaning is that I can’t put the right MacVim window where I want it and then hide the rest. OS X doesn’t let you hide individual windows, just entire applications; it also doesn’t seem to expose a way to minimize windows via its APIs. All I can do is move all of the MacVim windows to where I want the blog composition window, and then switch to it and leave the others behind it.

Something similar applies to iTerm, where I had to use the same workaround (if you can even call it that).

Finally, I was disappointed to learn that Slate doesn’t provide a hide() method on an application, but rather makes you call a generic hide function that you pass a set of names to. I went to a lot of trouble to figure out how to distinguish between the instances by attributes other than their names—which is how I can get the different Chromes to move to the right places—and being unable to use that work when calling hide() is unpleasant.

So instead of being able to invoke the Slate function, I currently have to invoke it, manually hide the Chrome instances I don’t want, and manually focus the MacVim and iTerm windows I want at the front. I also have to manually hide other applications (although that is probably fixable).

In many ways this is a classic example of programmer’s folly:

  • I’ve done without the technology to do this for a long time.
  • It’s not actually that important.
  • It would be nice to have.
  • Achieving requires programming.
  • It involves bending the system to your will.
  • It seems like it should be possible without having to go too crazy.
  • It has partial solutions that suggest the whole solution isn’t very distant.

I hope to have figured some more of it out by next week, and will provide the code that I’m using to do this when I’ve done so[1].

[1] Less optimistically, I might end up failing to get any further, but I’ll still put the code/tricks up at some point.

One Response to “Yak-Shaving with Slate”

  1. jeffliveshere Says:

    You are particular about your digital workspace? I’m shocked.

Leave a Reply