Skip to content

Instantly share code, notes, and snippets.

@jsanders
Created July 9, 2014 18:16
Show Gist options
  • Save jsanders/743700076af2853b7373 to your computer and use it in GitHub Desktop.
Save jsanders/743700076af2853b7373 to your computer and use it in GitHub Desktop.
Hydra bindings for screen quarters
-- Returns a function that can be used to move into quarter grid
function quarter(horiz, vert)
local win = window.focusedwindow()
local newframe = win:screen():frame_without_dock_or_menu()
local halfw = newframe.w / 2
local halfh = newframe.h / 2
newframe.h = horiz == "full" and newframe.h or halfh
newframe.w = vert == "full" and newframe.w or halfw
newframe.y = horiz == "bottom" and halfh or newframe.y
newframe.x = vert == "right" and halfw or newframe.x
return function () win:setframe(newframe) end
end
-- Full Screen
hotkey.new({"ctrl", "alt"}, "SPACE", quarter("full", "full")):enable()
-- Horizontal and vertical halves
hotkey.new({"ctrl", "alt"}, "LEFT", quarter("full", "left")):enable()
hotkey.new({"ctrl", "alt"}, "RIGHT", quarter("full", "right")):enable()
hotkey.new({"ctrl", "alt"}, "UP", quarter("top", "full")):enable()
hotkey.new({"ctrl", "alt"}, "DOWN", quarter("bottom", "full")):enable()
-- Quarters
hotkey.new({"ctrl", "alt", "cmd"}, "LEFT", quarter("top", "left")):enable()
hotkey.new({"ctrl", "alt", "cmd"}, "UP", quarter("top", "right")):enable()
hotkey.new({"ctrl", "alt", "cmd"}, "RIGHT", quarter("bottom", "right")):enable()
hotkey.new({"ctrl", "alt", "cmd"}, "DOWN", quarter("bottom", "left")):enable()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment