Skip to content

Instantly share code, notes, and snippets.

@garriguv
Created October 25, 2015 18:41
Show Gist options
  • Save garriguv/49bd7e6fc048e0094346 to your computer and use it in GitHub Desktop.
Save garriguv/49bd7e6fc048e0094346 to your computer and use it in GitHub Desktop.
Mjolnir configuration
local hotkey = require "mjolnir.hotkey"
local window = require "mjolnir.window"
local screen = require "mjolnir.screen"
local modifier = {"cmd", "alt", "ctrl"}
-- left half
hotkey.bind(modifier, "left", function()
local win = window.focusedwindow()
local screenFrame = screen.mainscreen():frame()
local frame = win:frame()
frame.x = 0
frame.y = 0
frame.w = screenFrame.w / 2
frame.h = screenFrame.h
win:setframe(frame)
end)
-- right half
hotkey.bind(modifier, "right", function()
local win = window.focusedwindow()
local screenFrame = screen.mainscreen():frame()
local frame = win:frame()
frame.x = screenFrame.w / 2
frame.y = 0
frame.w = screenFrame.w / 2
frame.h = screenFrame.h
win:setframe(frame)
end)
-- center resize
hotkey.bind(modifier, "up", function()
local win = window.focusedwindow()
local screenFrame = screen.mainscreen():frame()
local frame = win:frame()
frame.w = screenFrame.w / 1.5
frame.h = screenFrame.h / 1.5
frame.x = screenFrame.w / 2 - frame.w / 2
frame.y = screenFrame.h / 2 - frame.h / 2
win:setframe(frame)
end)
-- center
hotkey.bind(modifier, "down", function()
local win = window.focusedwindow()
local screenFrame = screen.mainscreen():frame()
local frame = win:frame()
frame.x = screenFrame.w / 2 - frame.w / 2
frame.y = screenFrame.h / 2 - frame.h / 2
win:setframe(frame)
end)
-- full screen
hotkey.bind(modifier, "space", function()
local win = window.focusedwindow()
local screenFrame = screen.mainscreen():frame()
win:setframe(screenFrame)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment