
Hydra: A lightweight OS X window manager with a powerful API - LaSombra
https://github.com/sdegutis/hydra
======
sergiotapia
If you're looking for a window manager for OSX without having to actually
configure anything, you can try using Spectacle:
[http://spectacleapp.com/](http://spectacleapp.com/)

For instance on my imac 27'' I have Option+Command+Left|Right keys mapped to
side (similar to windows 7.

And I can also have 4 windows open at once using
Shift+Option+Command+Up|Down|Left|Right to move them to the different corners.
Works really well with less than 2 minutes of setting the hotkey on a simple
GUI configuration window.

~~~
m_t
I can't find the minimum OSX version on the Spectacle site or github. Do you
have any idea which one it is?

~~~
chriskelley
ShiftIt is extremely similar to Spectacle (I use both on different machines)
and should be functional back to 10.6.

[https://github.com/fikovnik/ShiftIt](https://github.com/fikovnik/ShiftIt)

------
colinramsay
This looks great, but my favourite thing might be the Principles section:

    
    
      > Hydra must be stable. It should never crash
      > Hydra must be lightweight... never use more than 10 MB of memory
      > API should be completely transparent
      > API must not be bloated
    

I think these principles should be the standard to which we all hold our
software. Looking forward to testing this out!

Edit to say: it would be really great to see some more complete code samples
but I'm sure that'll come in time.

~~~
chc
I don't think "Must never use more than 10 MB of memory" is a reasonable
standard to hold all software to.

~~~
kennywinker
Nope, but I would venture to guess that most software would be improved by
sticking to that.

~~~
chc
I don't even feel confident in that claim. If keeping memory usage under 10 MB
requires a significant amount of developer effort, that is effort that isn't
going into something else that I might value a lot more than, say, 20 MB of
RAM.

~~~
georgemcbay
Not just developer effort, but also sometimes program runtime efficiency. RAM
is cheap, RAM is pretty fast (compared to disk or network); cache shit there
when it makes sense to do so for overall efficiency.

10MB is a fairly ridiculous modern standard to limit yourself to, IMO (and I
started on the C64 and generally do dislike and try to avoid bloat).

------
Walkman
I tried a ton of window managers (Divvy [1], Spectacle [2], Alfred worflows,
scripts) over the years, but _the most advanced_ , most easy to use and
fastest solution is Moom [3]. It's extremely flexible, configurable, have nice
design and clever tricks. It has far more features that all of the above. I'm
not searching the perfect window manager anymore.

[1]: [https://mizage.com/divvy/](https://mizage.com/divvy/)

[2]: [http://spectacleapp.com/](http://spectacleapp.com/)

[3]: [http://manytricks.com/moom/](http://manytricks.com/moom/)

~~~
saidajigumi
I'll second the motion for Moom. Great app, but I'm really glad to see some
viable OSS solutions in this space. Environment hacking FTW.

I'll also mention a feature I adore from FlexiGlass[1]: the ability to map
<modifier>-<1/2/3 finger move> to move the window under the mouse. For
example, I use <option>-<2 finger move> for this mapping. No mouse click &
hold required, and the entire window is the "hit zone". FlexiGlass can also
resize similarly, but I tend to just use my Moom bindings to snap windows
where I want them.

I find this to be _incredibly_ pleasant to use for window moves because it's a
very immediate experience, more like arranging paper on your desk. Even
better, the window being moved doesn't have to be in the frontmost
application. This makes it even faster to move background windows. The usual
window movement via titlebar or window snapping app requires the moved window
be frontmost/focused, so there's a switching back and forth required. Between
the giant, whole window, hit area and less focus switching, FlexiGlass'
approach is a huge win IMO. I still feel a bit self-conscious about having
this app installed for _one feature_ , but it's really that good.

[1] [http://nulana.com/flexiglass/](http://nulana.com/flexiglass/)

~~~
jdechko
I started with the moom trial, but when it came time for me to make a
purchase, I ended up going with BetterSnapTool. It might not be quite as
flexible as Moom, but a) it fit my personal needs and b) it was less than half
the price.

------
typicalbender
I miss my days on Ubuntu with i3 tiling window manager. I currently use an app
called Amethyst[1] but find it to be a bit buggy at times and just doesn't
live up to i3 or awesome. I wonder if hydra can be used as a launch point to
create a better tiling window manager for OSX. I'm not familiar with the APIs
that OSX exposes, if any, to do things like window management but it would be
awesome to see some more control over workspaces and not just the windows
within a workspace.

[1] [https://github.com/ianyh/Amethyst](https://github.com/ianyh/Amethyst)

~~~
peatmoss
Amethyst is the first tiling window manager I've used for any substantial
length of time. I made my desktop transition from NetBSD -> OSX before tiling
window managers were really much used. Amethyst gets props from me in being
the first that has worked intuitively and stabily such that I've actually
stuck with it for any length of time.

As for Linux, I realize that I'm personally in a place where leaving OSX would
cause me no grief whatsoever. I catalogued everything I run on my Mac these
days, and was pleasantly surprised to find I have zero local commercial
software that I depend on, or indeed any Mac-only software. Generally, when
I've used recent Linux desktops, I've discovered that the experience is at
least on par with my Mac, with the added bonus that Emacs doesn't have so many
quirks.

Battery life on my MacBook Air is really the only thing keeping me from moving
back. I have to wonder if there is any movement to achieve power management
parity with OSX in Linux.

~~~
nextos
I was in the same position and switched to Arch long ago. Power management in
my MacBook Air 11 2013 is as good as in OS X, if not better. This sounds like
a bold statement, but mind that it's almost 100% Intel hardware. Intel funded
powertop, which is a utility that allows you to track and optimize software
and hardware power usage.

Even Linus himself used this machine for quite long. He then moved on to a
Chromebook Pixel. These days he seems to be using a Vaio.

~~~
andor
How long does your battery last under Linux, with reasonable screen
brightness? What's the battery discharge rate indicated by powertop? Are you
using a full desktop environment?

~~~
nextos
I run a very minimalistic environment without a DE. I use XMonad as a WM. My
only graphical applications are Firefox and Zathura.

With wireless on, while browsing the web, powertop shows around 5.2W. This is
with a pretty bright screen. With reasonable usage, you can go well past 5
hours. Note this machine has a tiny battery in comparison to the 13 inch
model.

I believe things could be even better (-0.5W) if I used another driver for the
Broadcom wireless card (currently using the stock one in the kernel), as it
doesn't support power management. Besides, on X11 the keyboard and the
trackpad do not sleep properly.

Best hardware I've seen in this regard was a X220, and a Nokia N9. But the Mac
is extremely good. If one cherry picks hardware for Linux like Apple does for
OS X, the experience can be very good these days.

~~~
peatmoss
Hmm... Even 5 hours is pretty low compared to what I get under OSX with
normalish usage on my MBA 11". I've also found that I get markedly better
battery life when I connect to my Apple-branded wifi base station than when I
connect to wifi just about anywhere else. This makes me wonder if Apple
doesn't have some proprietary power scaling stuff with the wifi. Still, 5
hours is good enough that I might consider a more thorough checking out.

EDIT: I should add that I've only spent time in 10.9 on this MBA 11 2013
model. I've been told the battery life in 10.9 really is quite a lot better
than in 10.8.

~~~
nextos
Well, with comparable usage I was getting perhaps 20 extra min on OS X. It's
very good I think. It's pretty clear when you check sensor temperature: both
machines are equally cold.

In the old (and not so old) times, laptops with horrid Linux power management
would be extra warm due to all components being powered up all time. Far from
it right now, if you cherry pick hardware. There's still room for improvement,
though.

------
tnorthcutt
I've been using Slate[1] for a while which may be worth considering as an
alternative. Hydra does look pretty slick, though!

[0] [https://github.com/jigish/slate](https://github.com/jigish/slate)

~~~
mrmch
I'm another Slate user -- looks like Hydra is a spiritual successor... I'll
give it a go.

~~~
holyjaw
Ah I had no clue Slate wasn't actively maintained anymore. I just caught up
with the new JS API. Damnit. Well, guess I'll look at Hydra now...

------
Dirlewanger
Another amazing OS X WM: Sizeup
([https://www.irradiatedsoftware.com/sizeup/](https://www.irradiatedsoftware.com/sizeup/))

No config, all shortcuts bound to Ctrl + Option + Command + arrows and a few
others. They have an unlimited free trial, but pay for it if you really use
it.

~~~
Synergyse
+1 for SizeUp, tried most of them and prefer this app.

~~~
kirklove
+2. Can't live without it. I'm paralyzed on a machine without it (or Alfred)

------
sdegutis
Project Author here: Thanks everyone for making Hydra bypass Zephyros as my
most starred project! (Especially considering Zephyros is deprecated in favor
of Hydra, and I can't really delete Zephyros since people might still be using
it.)

------
btown
For the "closed-source-but-non-programming-power-user" alternative to this,
I'm a huge advocate of BetterTouchTool
([http://www.boastr.net/](http://www.boastr.net/)). You can easily bind window
snaps to everything from keypresses, to four-finger-sweeps on the trackpad, to
dragging window titlebars to the screen corners. Also it's so much fun to
infuriate friends when they try to use my trackpad and it moves windows all
over the place.

~~~
BozeWolf
I Quickly had a look on all the window manager alternatives mentioned here.
Currently I use flexiglass, but I use it for one reason only. It allows me to
move windows like in linux.

When holding Mouse button 1 + alt anywhere in the window I can move it. I
really like this feature, I never use the titlebar to move windows.

Do any of the alternatives (or hydra it self) allow me to do this? I'd like to
try them out. See if it has advantages over flexiglass.

~~~
jmgao
Shameless plug:
[https://github.com/jmgao/metamove](https://github.com/jmgao/metamove)

~~~
barbs
Just what I've been looking for! Thanks for this :)

------
athenot
Wouldn't F-Script[1] achieve the same? I'm not sure how much love it's
received for Mavericks but it's a great way to peek into any Cocoa app and
call methods.

[1] [http://www.fscript.org](http://www.fscript.org)

------
bradbatt
I have used Divvy in the past, but now use Keyboard Maestro for window
management.
([http://www.keyboardmaestro.com/](http://www.keyboardmaestro.com/))

You do have to configure things and set them up a bit, but it can do SO much
more than just window management.

Just throwing another option out there…For me, Keyboard Maestro is one of
those must-have programs like Alfred or Hazel—totally changes how you do
things.

------
mgrouchy
Interesting. I use Moom for this
[http://manytricks.com/moom/](http://manytricks.com/moom/), but I will give
this a try.

------
D4AHNGM
This thread really does show the best of Hacker News. I wandered in here
intrigued by Hydra and ended up checking out 3 or 4 open-source pieces of
software that do similar things thanks to recommendations here.

The choice is absolutely brilliant. I love seeing so many open-source
recommendations. I went for Spectacle in the end, but I'll definitely be
keeping an eye on Hydra and seeing how it progresses.

~~~
tiles
I agree that this discussion has been enormously helpful. On first glance, I'm
was very disappointed that this thread seems __only __to be about
alternatives, not discussing the product at hand. If this were an announcement
of a product, it would be disappointing to only have people discuss how
excited they were about other software that isn 't mine.

But your comment made me realize it's just about ego—I'm definitely
benefitting from this discussion and should admit as much!

------
weavie
This looks great. Will try it out. It has always surprised me how OS X has
such a poor window placement story given how much emphasis apple seems to
place on User Experience.

~~~
omaranto
I don't there is anything too surprising about this. "User Experience" isn't
something you can measure on a single line, there are different aspects to it.
I'm not an expert but I think the following are some of the things that users
can appreciate:

1\. That things work smoothly.

2\. That things look pretty.

3\. That it's easy to figure out what a program does when you first use it.

4\. That it's possible to control the program efficiently, i.e., that you can
quickly activate a program's different functions.

5\. That a program is powerful, in that it enables you to customize it to work
exactly as you need and automate it's use.

I've heard people claim Apple focuses on 1-3, I've never heard people say
Apple focuses on 4 and 5. For windows placement in particular, Mac OS (as
practically all window managers) has a method that covers 1-3: move and resize
with the mouse.

~~~
weavie
Maybe its just because I came from Windows, but I generally expect hitting the
maximize button to take the app to take up the whole screen space. On OS X,
some apps do and some don't.

This violates #3 for me.

Another one is minimizing a window and then Alt-Tabbing to it (whatever the
Mac equivalent is..) doesn't bring that window back up.. You are just left
staring at the same app.

This violates #1 for me.

~~~
chrisoverzero
Maybe it is indeed because you come from Windows, but OS X doesn't have a
Maximize button. The green light of OS X's traffic-light configuration is
Zoom. But it's becoming Full Screen in Yosemite, so that should be closer to
what you want out of the button.

As to your second point, that probably has the same cause. On OS X, you Cmd-
Tab between applications, not between windows. Within an application, you can
Cmd-Backtick between windows, but I don't think there's a navigatable
collection of all windows across all applications.

------
paultannenbaum
I have a somewhat related question for anyone with chrome devtools experience.

Is it possible to control the size (width and height) of the chrome debugger
panel using the devtools api? I want to build a chrome extension that provides
window management like Hydra or spectacle, but for the developer tools window.
Building hot keys that could do things like send the console window exactly
half screen in any direction or full screen, and also the same controls for
the second console window. I spend a lot of time in the developer panel (as
I'm sure many people do) and think a window manager could be a huge help. I
read the api docs fairly thoroughly and also posted this same question to the
google group and the stack overflow group with no response to either. Anyone
out there know?

~~~
r-cid
Unfortunately, it doesn't appear to be possible. See
[https://groups.google.com/a/chromium.org/forum/#!topic/chrom...](https://groups.google.com/a/chromium.org/forum/#!topic/chromium-
dev/lKzLtlRZXrM)

~~~
paultannenbaum
Thank you! I searched google groups but was unable to find something like
this. I did try and code up a simple prototype and ran into the same scope
issues as the author of the linked thread.

------
sdegutis
Welp, my sample config's REPL command was broken in the beta that everyone
downloaded. And my first attempt at fixing it didn't actually work. It works
on Beta 6. Nothing like my project being #2 on HN to make me rush enough to
need two tries to fix a 1-line bug, heh.

~~~
dbailey5
Hey I'm checking out your config file now, Where can I get the grid package
you are using?

~~~
sdegutis
[https://github.com/sdegutis/hydra/wiki](https://github.com/sdegutis/hydra/wiki)

------
peterhajas
Looks really cool! I was using
[slate]([https://github.com/jigish/slate](https://github.com/jigish/slate)),
but it seems to be abandonware.

I have a couple of things I'd like:

\- A
[Divvy]([http://mizage.com/divvy/)-style](http://mizage.com/divvy/\)-style)
grid. When I used Divvy, this really made a dramatic difference in my window
management \- Rich Spaces/Mission Control support. It'd be great to send
windows to certain spaces, make spaces for windows, etc.

I'm excited to write a Hydra config for myself, it seems great!

------
cik
I've been using IrradiateSoftware's sizeup for years, and have never looked
back.... until I came back to a Linux desktop.

------
zzygan
Is there a way to do XMonad style layouts with this system? Since moving to
OSX, I've missed Xmonad badly. The big thing that has been lacking is the
ability for newly opened windows to automatically be placed into a grid,
according to the layout that is currently defined, and then have the ability
to shuffle windows around within that layout.

~~~
sdegutis
That should be a really easy config, especially after events are added in 1.1;
I'll see what I can do it create it and add it to the wiki, unless someone
beats me to it :)

------
hamburg
I wrote my own window manager a few weeks ago:
[http://zonesformac.com](http://zonesformac.com)

Emphasis is on support for multiple screens, ease of use and snappiness.
(which doesn't come across in my video I guess...)

I know my download page sucks, but if anyone wants to try and give me
feedback, I'd be happy to read it. Send an email.

~~~
sdegutis
Looks pretty neat. Reminds me of Moom, and the defaults Windows 7 drag-to-
position features.

------
c141charlie
Can we stop naming software "Hydra"? At my company alone there are several
tools and libraries that go by the name of Hydra. Each time someone refers to
Hydra, you have to clarify which tool/library they are talking about.

~~~
sdegutis
Naming things is the hardest part of writing software. Really it is.

~~~
Yetanfou
Nah, not really. Just get yourself a Swahili dictionary and you're set for a
whole bunch of projects. They'll have similar names to mine (Rafiki, Nena,
Chombo, Sanduku, Ramani, ...) but they'll be easily pronounceable, well-
sounding and with a bit of luck even still available in .com/.net/.org/.two-
letter-country-code-du-jour.

~~~
coreyja
That's actually really good advice, thanks.

------
tjl
I find this quite intriguing, but Optimal Layout,

[http://most-advantageous.com/optimal-layout/](http://most-
advantageous.com/optimal-layout/)

basically has most of my needs covered.

------
Cacti
Looks promising but how is multi monitor support? And how easy would it be to
detect whether I am on my 1 screen laptop or 3 screen desktop, and use
different setups accordingly?

~~~
sdegutis
I believe `screen.allscreens()[1]` always represents the current "primary
screen". So yeah it should be possible.

------
kovrik
Is it possible to move windows from one desktop to another?

~~~
Nemcue
It probably is. I used Phoenix (the JS predecessor to Hydra) and that exact
functionality is one of my most used hotkeys:

Capslock + E = Swap currently selected window to other desktop, make that
window fullscreen and center the mouse cursor on it

------
tsenkov
Looks awesome.

But I have some issues I can't seem to resolve - I saved the sample config in
the specified path (it should be correct since on reload the app says "Hydra
sample config loaded"), but I can't open the repl (Hydra Error: "Attempt to
call a nil value"). And using the Cmd+Ctrl+Alt+J doesn't make the window
shorter, only moves it to the right (going out of the screen).

I am sure this is just a beta release hiccup.

~~~
sdegutis
Yep, that was indeed an error. Tried fixing it, released beta5. Actually fixed
it, released beta6. Nothing like being on the front page of HN to make me rush
enough to mess that up one-line-fix on the first try. :)

~~~
tsenkov
Unfortunately, I still get the same errors.

------
joshka
Cool tool. Would be a good idea to get it on homebrew for one liner install. I
noticed when checking whether it was on homebrew that there's another piece of
software already by that name that could be worth avoiding (despite being an
almost perfect name for what this does).

~~~
sdegutis
I think GUI apps only go in cask[1] not homebrew. But yeah, totally a good
idea to put it in there. Thanks! Can you file an issue for this in Hydra?

[1]: [http://caskroom.io/](http://caskroom.io/)

------
dbailey5
Any idea what his require grid is referring to in his own config file?

link -
[https://github.com/sdegutis/dotfiles/blob/osx/home/.hydra/in...](https://github.com/sdegutis/dotfiles/blob/osx/home/.hydra/init.lua)

~~~
sdegutis
It refers to the grid.lua[1] file in the same directory as that init.lua. It's
also found in the wiki[2].

[1]:
[https://github.com/sdegutis/dotfiles/blob/osx/home/.hydra/gr...](https://github.com/sdegutis/dotfiles/blob/osx/home/.hydra/grid.lua)

[2]: [https://github.com/sdegutis/hydra/wiki/Useful-Hydra-
librarie...](https://github.com/sdegutis/hydra/wiki/Useful-Hydra-libraries)

------
Justsignedup
I've been using slate, but I must admit the API for it is not that incredible
(certain math operations are not very elegant) --
[https://github.com/jigish/slate](https://github.com/jigish/slate)

------
chrisdevereux
Looks great! Have been looking for a Slate replacement for a while...

Have you considered adding Lua calls for accessing and modifying window
contents, selections, etc? OS X has a rich collection of APIs for doing this
via Scripting Bridge and AXAccessibility.

~~~
sdegutis
Hmm yeah, that would be pretty cool! Can you file an issue for this feature
request?

------
pepijndevos
I actually rolled my own WM with some AppleScript. Here is one of my scripts
that divides the screen between the two frontmost applications.

[https://www.refheap.com/87844](https://www.refheap.com/87844)

~~~
sdegutis
Wow, that is really neat!

------
cksachdev
Works like a charm. Can think of an enhancement:

[https://github.com/sdegutis/hydra/issues/134](https://github.com/sdegutis/hydra/issues/134)

What do you think? No voting system in github :(

------
halayli
I am pretty happy with zooom2. It gave my wmaker features back.

[http://www.coderage-software.com/zooom/index.html](http://www.coderage-
software.com/zooom/index.html)

------
afarrell
I've been using
[https://github.com/ianyh/Amethyst](https://github.com/ianyh/Amethyst) for a
couple weeks and have been pretty happy with it.

------
shoyer
Is there support for saving/restoring window layouts? I find that feature very
handy in Slate when removing/adding external monitors.

~~~
sdegutis
There's an issue in the 1.1 milestone for adding the event that an external
monitor was added/removed. Once you have that, I don't see what's stopping you
from creating this feature :)

------
philsnow
sdegutis: would it be possible to get spaces / mission control into the API?
That is, if it's not already there; I looked in every module and couldn't find
anything that looked applicable. Farthest I got was
screen.mainscreen()["__screen"], which is a userdata.

~~~
sdegutis
Probably. I think Amethyst does this, so we should be able to too. Can you
file an issue for this feature request? Thanks.

~~~
philsnow
[https://github.com/sdegutis/hydra/issues/116](https://github.com/sdegutis/hydra/issues/116)

------
voltagex_
Is there anything like this for Windows?

~~~
foresterh
I've been using WinSplit Revolution for years and love it. It's not
extensible, but lets you do things like toggle between 1/3, 1/2, and 2/3 of
the space, which I use a lot.

------
andylei
cool!

one thing that kind of bugs me is that when you reload the config file, if
there's something wrong with it, it just loads the fallback config. i don't
see any error messages, so its hard to figure out what i did wrong in the
config.

~~~
sdegutis
It should be showing error messages as a notification, found in notification
center. Also, error messages should be automatically appended to
`logger.lines`, which you can browse in a textgrid using `logger.show()`.

------
kovrik
Awesome work, sdegutis!

I love your Zephyros and Phoenix projects. Keep working!

I really miss good tiling wm on MacOS X.

~~~
sdegutis
<3

------
stuaxo
Can one of these window managers support focus follows mouse on OSX ?

------
xbryanx
This looks great, and reminds me of AutoIt on Windows in some ways.

------
cmsj
Note: beta7 is out as of 90 minutes ago, everyone update!

------
tylermac1
Definitely going to give this a try. Looks great.

------
calgaryeng
I've had a ton of success with Slate, FWIW.

------
signa11
please do mention that this is available on releases >=10.9

------
adouzzy
All I ask for is an awesome wm.

~~~
sdegutis
Well played.

------
mu_killnine
Hail Hydra!

...sorry, just saw Winter Soldier this week.

