Skip to content

Instantly share code, notes, and snippets.

@garriguv
Created October 25, 2015 19:02
Show Gist options
  • Save garriguv/ab65283e6b68bc88185e to your computer and use it in GitHub Desktop.
Save garriguv/ab65283e6b68bc88185e 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 grid = require "mjolnir.bg.grid"
grid.MARGINX = 0
grid.MARGINY = 0
grid.GRIDWIDTH = 8
grid.GRIDHEIGHT = 8
local resize = function(x, y, w, h)
return function()
win = window.focusedwindow()
grid.set(win, {x=x, y=y, w=w, h=h}, win:screen())
end
end
local modifier = {"cmd", "alt", "ctrl"}
-- full screen
hotkey.bind(modifier, "space", grid.maximize_window)
-- left half
hotkey.bind(modifier, "left", resize(0, 0, grid.GRIDWIDTH / 2, grid.GRIDHEIGHT))
-- right half
hotkey.bind(modifier, "right", resize(grid.GRIDWIDTH / 2, 0, grid.GRIDWIDTH / 2, grid.GRIDHEIGHT))
-- 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.3
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment