Skip to content

Instantly share code, notes, and snippets.

@sixfeetover
Created November 24, 2014 15:40
Show Gist options
  • Save sixfeetover/121790a888c1f751ebee to your computer and use it in GitHub Desktop.
Save sixfeetover/121790a888c1f751ebee to your computer and use it in GitHub Desktop.
Mjolnir config
local application = require "mjolnir.application"
local fnutils = require "mjolnir.fnutils"
local hotkey = require "mjolnir.hotkey"
local window = require "mjolnir.window"
local alert = require "mjolnir.alert"
hotkey.bind({"cmd", "alt", "ctrl"}, "D", function()
local win = window.focusedwindow()
local f = win:frame()
f.x = f.x + 10
win:setframe(f)
end)
-- Move the window to a particular 1/4 of the screen
local quarter = function(x, y, keycode)
hotkey.bind({'ctrl', 'alt', 'cmd'}, keycode, function()
local win = window.focusedwindow()
win:movetounit{x = x, y = y, w = 0.5, h = 0.5}
end)
end
local third = function(x, y, keycode, factor)
hotkey.bind({'ctrl', 'alt', 'cmd'}, keycode, function()
local win = window.focusedwindow()
win:movetounit{x = x, y = y, w = 1/3 * factor, h = 1}
end)
end
-- Move the window to a particular half of the screen
local horizontal_half = function(x, y, keycode)
hotkey.bind({'ctrl', 'alt', 'cmd'}, keycode, function()
local win = window.focusedwindow()
win:movetounit{x = x, y = y, w = 0.5, h = 1}
end)
end
local vertical_half = function(x, y, keycode)
hotkey.bind({'ctrl', 'alt', 'cmd'}, keycode, function()
local win = window.focusedwindow()
win:movetounit{x = x, y = y, w = 1, h = 0.5}
end)
end
-- centered, big, not quite full screen
hotkey.bind({'ctrl', 'alt', 'cmd'}, 'c', function()
local win = window.focusedwindow()
win:movetounit{x = 1/10, y = 1/10, w = 0.8, h = 0.8}
end)
-- These next four commands create a 2x2 grid, which matches the keyboard:
-- U I
-- J K
quarter(0.0, 0.0, 'u') -- top left
quarter(0.5, 0.0, 'i') -- top right
quarter(0.0, 0.5, 'j') -- bottom left
quarter(0.5, 0.5, 'k') -- bottom right
third(0.0, 0.0, 'o', 1) -- left third
third(0.0, 0.0, 'p', 2) -- left two-thirds
third(2/3, 0.0, ']', 1) -- right third
third(1/3, 0.0, '[', 2) -- right two-thirds
-- Move to half of the screen
horizontal_half(0, 0, 'left') -- left
horizontal_half(0.5, 0, 'right') -- right
vertical_half(0, 0, 'up') -- top
vertical_half(0, 0.5, 'down') -- bottom
-- Maximize
hotkey.bind({'cmd', 'alt', 'ctrl'}, 'M', function()
local win = window.focusedwindow()
win:maximize() --movetounit{x = 0.01, y = 0.01, w = 0.95, h = 0.95}
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment