Div — a simple Alfred window manager
There are tons of window managers for Mac OS X around. Chris Coyier published a nice comparison of the most popular ones some time ago. These apps are great utilities that can boost your productivity by eliminating the time that you normally spend adjusting the window positions on your sceen. I was using Divvy by Mizage for a long time and it worked like a charm for me. Another app that I use non-stop is Alfred. It looks like the default Spotlight search feature but it is much more powerful than that. It allows you to create advanced search functionality, custom hotkeys, explore files, control apps, store snippets, use clipboard history and so on. The app in itself is a subject that deserves a separate article (expect one soon).
Being uber minimalistic in terms of my workflow I decided to create a windows manager for Alfred. Say hello to Div! It is a simple Applescript (which incidentally was great fun to learn) with many triggers attached to it. I even created a logo for it :)
How to use Div
As I mentioned previously — Div is a simple script with many options to control it. You can download it from Packal — a community driven repository of the best Alfred workflows. It comes with some predefined layout settings, but it’s dead easy to add custom ones. It is written in Applescript — a very basic scripting language to do practical but also cool stuff on Apple computers.
Enable access for assistive devices (required)
Applescript works nicely with the majority of Mac OS X applications. Unfortunately some of them are non-scriptable. The solution is not to control app’s position but the window around it. We need to give Alfred access for assistive devices first. Just follow these easy steps:
- Open System Preferences
- Go to Security & Privacy
- Go to Privacy tab
- Go to the Accessibility on the left panel
- Click the lock and type your password
- Click small + icon and add Alfred from the list
- Done :)
Predefined list of layouts
Div comes with a predefined list of layouts. To use one simply type
div and choose an option from the list.
There are a few predefined hotkeys. It is probably the quickest and most efficient way to manage your layouts. That’s how I use it mainly.
⌃ ⌥ 1Full
⌃ ⌥ 2Medium
⌃ ⌥ 3Small
⌃ ⌥ ←Left
⌃ ⌥ →Right
⌃ ⌥ ↑Top
⌃ ⌥ ↓Bottom
Sometimes predefined settings are not enough. Div knows how to deal with these situations. It allows you to pass custom arguments to create a custom position. It accepts two or four arguments.
Choose custom boundaries by passing 4 space-separated values. For example
div 20 20 80 80 will place the top left corner of an app 20% from the top and 20% from the left edge of the screen, and the bottom right corner 80% from the top and 80% from the left edge of the screen.
Choose a custom size by passing 2 (space separated) values. For example
div 800 600 will resize your window to 800px wide and 600px high and place the window in the middle of the screen.
Thanks for using Div
Hopefully you will find it useful. If you need something more advanced have a look at the amazing Alfred 2 layout workflow by Bodo Junglas. As always, user feedback is welcome. Use the comments section below to share your love, opinions or report any bugs. If you would like to help me in the future development of Div feel free to fork it on Github and send a pull request. Enjoy :*comments powered by Disqus