-
-
Save cmsj/a590bf73dd0a4b271074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "grid" | |
ext.grid.MARGINX = 0 | |
ext.grid.MARGINY = 0 | |
hydra.alert "Hail hydra!" | |
pathwatcher.new(os.getenv("HOME") .. "/.hydra/", hydra.reload):start() | |
autolaunch.set(true) | |
menu.show(function() | |
return { | |
{title = "About Hydra", fn = hydra.showabout}, | |
{title = "-"}, | |
{title = "Quit", fn = os.exit}, | |
} | |
end) | |
-- Define some keyboard modifier variables | |
-- (Note: Capslock bound to cmd+alt+ctrl+shift via Seil and KeyRemap4MacBook) | |
local alt = {"alt"} | |
local hyper = {"cmd", "alt", "ctrl", "shift"} | |
-- Helper functions | |
function left30() | |
local f = window.focusedwindow() | |
local screenrect = window.focusedwindow():screen():frame_without_dock_or_menu() | |
f.w = screenrect.w * 0.3 | |
f.h = screenrect.h | |
f.x = screenrect.x | |
f.y = screenrect.y | |
f:setframe(f) | |
end | |
function right70() | |
local f = window.focusedwindow() | |
local screenrect = window.focusedwindow():screen():frame_without_dock_or_menu() | |
f.w = screenrect.w * 0.7 | |
f.h = screenrect.h | |
f.x = screenrect.x + screenrect.w - f.w | |
f.y = screenrect.y | |
f:setframe(f) | |
end | |
function lefthalf() | |
local f = window.focusedwindow() | |
local screenrect = window.focusedwindow():screen():frame_without_dock_or_menu() | |
f.w = screenrect.w * 0.5 | |
f.h = screenrect.h | |
f.x = screenrect.x | |
f.y = screenrect.y | |
f:setframe(f) | |
end | |
function righthalf() | |
local f = window.focusedwindow() | |
local screenrect = window.focusedwindow():screen():frame_without_dock_or_menu() | |
f.w = screenrect.w * 0.5 | |
f.h = screenrect.h | |
f.x = screenrect.x + (screenrect.w * 0.5) | |
f.y = screenrect.y | |
f:setframe(f) | |
end | |
-- VI style window navigation | |
hotkey.bind(hyper, 'h', function() window.focusedwindow():focuswindow_west() end) | |
hotkey.bind(hyper, 'l', function() window.focusedwindow():focuswindow_east() end) | |
hotkey.bind(hyper, 'j', function() window.focusedwindow():focuswindow_south() end) | |
hotkey.bind(hyper, 'k', function() window.focusedwindow():focuswindow_north() end) | |
-- Move windows between screens | |
hotkey.bind(hyper, 'Left', ext.grid.pushwindow_prevscreen) | |
hotkey.bind(hyper, 'Right', ext.grid.pushwindow_nextscreen) | |
-- Resize windows absolutely | |
hotkey.bind(hyper, 'a', left30) | |
hotkey.bind(hyper, 's', right70) | |
hotkey.bind(hyper, 'f', ext.grid.maximize_window) | |
hotkey.bind(hyper, '[', lefthalf) | |
hotkey.bind(hyper, ']', righthalf) | |
-- Change grid size | |
hotkey.bind(hyper, '=', function() ext.grid.adjustwidth( 1) end) | |
hotkey.bind(hyper, '-', function() ext.grid.adjustwidth(-1) end) | |
-- Note: F13-F16 mapped to Fn-Ctrl-{Left,Right,Up,Down} with KeyRemap4MacBook | |
-- Move windows around grid with Fn-Ctrl-arrows | |
hotkey.bind({}, 'F15', ext.grid.pushwindow_up) | |
hotkey.bind({}, 'F13', ext.grid.pushwindow_left) | |
hotkey.bind({}, 'F16', ext.grid.pushwindow_down) | |
hotkey.bind({}, 'F14', ext.grid.pushwindow_right) | |
-- Resize windows around grid with Fn-Ctrl-Alt-arrows | |
hotkey.bind(alt, 'F15', ext.grid.resizewindow_taller) | |
hotkey.bind(alt, 'F16', ext.grid.resizewindow_taller) | |
hotkey.bind(alt, 'F14', ext.grid.resizewindow_wider) | |
hotkey.bind(alt, 'F13', ext.grid.resizewindow_thinner) | |
-- Debugging | |
hotkey.bind(hyper, 'm', function() repl.open(); logger.show() end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment