Giter Club home page Giter Club logo

hydra's Introduction

Hydra

Hack your OS X desktop environment

Hydra is a lightweight window manager with a powerful API and an extremely small footprint.

Build Status

Install

Don't install Hydra via cask. Instead, download the zipped binary directly from the the latest-release page; unzip the downloaded file, put the app somewhere permanent, and run it. You may need to right-click it and click "Open" the first time.

Hydra is currently in beta, but is very stable, seeing minor releases every day. While in beta, the API is subject to change. Within a week, it will come out of beta. You can check for updates via the updates module, to be notified when an update (beta or not) is available.

Usage

Hydra will look for ~/.hydra/init.lua and run it if it exists. But if you haven't written one yet, it will run a fallback config that gives you a menu bar icon that contains an option to open this sample config. You can paste its contents into your ~/.hydra/init.lua to get started with a really basic starter config.

Bookmark the official online docs! The index page has very handy and valuable information that's not found in this readme or the in-app documentation system.

Example

sample_config.lua (raw source)

Here's a convenient way to set it up with wget:

$ mkdir -p ~/.hydra && cd $_ && wget -O https://raw.githubusercontent.com/sdegutis/hydra/master/Hydra/Bootstrapping/sample_config.lua init.lua

Here's a snippet:

-- show a helpful menu
menu.show(function()
    local updatetitles = {[true] = "Install Update", [false] = "Check for Update..."}
    local updatefns = {[true] = updates.install, [false] = checkforupdates}
    local hasupdate = (updates.newversion ~= nil)

    return {
      {title = "Reload Config", fn = hydra.reload},
      {title = "Open REPL", fn = repl.open},
      {title = "-"},
      {title = "About", fn = hydra.showabout},
      {title = updatetitles[hasupdate], fn = updatefns[hasupdate]},
      {title = "Quit Hydra", fn = os.exit},
    }
end)

-- move the window to the right half of the screen
function movewindow_righthalf()
  local win = window.focusedwindow()
  local newframe = win:screen():frame_without_dock_or_menu()
  newframe.w = newframe.w / 2
  -- newframe.x = newframe.w -- uncomment this line to push it to left side of screen
  win:setframe(newframe)
end

hotkey.new({"cmd", "ctrl", "alt"}, "L", movewindow_righthalf):enable()

Executing commands externally

Hydra comes with a command line utility to allow execution of Lua code within Hydra from the command line or another process. To install it, type ipc.link() at the REPL. The documentation for this function can be found at doc.ipc.link from within the REPL, as usual. You'd use it like so:

$ hydra "hydra.alert('hello world')"          ## give it args
$ echo "hydra.alert('hello world')" | hydra   ## or stdin
$ man hydra                                   ## it even has a man-page!

Screenshots

Some brief examples of my own config:

Description Animated Screenshot
Using hotkeys to move and resize a window along a grid (source) grid.gif
Using a hotkey to open Dictionary.app and show an alert (source) dict.gif
Using the built-in REPL (source) repl.gif
Using the hydra tool to control Hydra from the command line (see ipc.link) ipc.gif

Principles

First and foremost, Hydra must be stable. It should never crash. You should only ever have to launch it once, and it should stay running until you quit it (or your computer restarts). No exceptions to this.

Secondly, Hydra must be lightweight. It should never do anything that drains your computer's battery. It should never poll for anything. And it should practically never use more than 10 MB of memory. Everything it does should feel instant and snappy, never sluggish or delayed.

Thirdly, its API should be completely transparent. There should be no surprises in how it's behaving, or what's being executed and when. It should be fully predictable.

Finally, the API must not be bloated. Nothing should be put into it except what's impossible or impractical to do in pure Lua, and what's extremely common and likely to be used in everyone's configs.

Resources

Resource Link
Hydra Documentation http://sdegutis.github.io/hydra/
Lua API http://www.lua.org/manual/5.2/#functions
Community Contributions https://github.com/sdegutis/hydra/wiki
Bug Reports https://github.com/sdegutis/hydra/issues
Feature Requests https://github.com/sdegutis/hydra/issues
General Discussion https://github.com/sdegutis/hydra/issues
IRC channel #hydrawm on freenode

Donate

I've worked hard to make Hydra useful and easy to use. I've also released it with a liberal open source license, so that you can do with it as you please. So, instead of charging for licenses, I'm asking for donations. If you find it helpful, I encourage you to donate what you believe would have been a fair price for a license:

Donate via PayPal

FAQ

  1. How does Hydra compare to Zephyros or Phoenix?

    Hydra is the successor to my older Phoenix and Zephyros projects.

  2. How does Hydra compare to Slate?

    They're both programmer-centric with mostly similar goals. Look over their APIs and see which one suits you better.

  3. How does Hydra compare to Spectacle, Moom, SizeUp, Divvy, etc?

    Hydra is intended for programmers who want to write programs that customize their environment. It's not intended to be a quick-and-easy solution, it's meant to allow you to write your own very personalized productivity enhancement suite to keep and use long-term.

  4. Can you add ____ feature?

    Maybe. File an issue and we'll find out!

  5. Where can I find a comprehensive and detailed list of alternatives to Hydra?

    https://news.ycombinator.com/item?id=7982514

License

Released under MIT license.

Copyright (c) 2013 Steven Degutis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

hydra's People

Contributors

alexkirsz avatar barneyb avatar benfb avatar christianberg avatar cmsj avatar ddfisher avatar dennisv avatar ericbottard avatar habbie avatar ihodes avatar jhgg avatar matthewmichihara avatar miksu avatar muescha avatar sennah911 avatar zef avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.