Skip to content

Instantly share code, notes, and snippets.

@teki
Created June 6, 2019 04:02
Show Gist options
  • Save teki/2c4c32d96eb5a970681333753d822829 to your computer and use it in GitHub Desktop.
Save teki/2c4c32d96eb5a970681333753d822829 to your computer and use it in GitHub Desktop.
local application = require "mjolnir.application"
local hotkey = require "mjolnir.hotkey"
local window = require "mjolnir.window"
local screen = require "mjolnir.screen"
local fnutils = require "mjolnir.fnutils"
function move_win_x(pos, div)
local win = window.focusedwindow()
local f = win:frame()
local s = win:screen():frame()
f.x = pos * (s.w / div)
f.w = s.w / div
f.y = 0
f.h = s.h
win:setframe(f)
end
function move_win_y(pos, div)
local win = window.focusedwindow()
local f = win:frame()
local s = win:screen():frame()
f.y = pos * (s.h / div)
f.h = s.h / div
f.x = 0
f.w = s.w
win:setframe(f)
end
-- thirds
hotkey.bind({"alt", "ctrl"}, "left", function()
move_win_x(0,3)
end)
hotkey.bind({"alt", "ctrl"}, "down", function()
move_win_x(1,3)
end)
hotkey.bind({"alt", "ctrl"}, "right", function()
move_win_x(2,3)
end)
-- halfs
hotkey.bind({"cmd", "alt", "ctrl"}, "left", function()
move_win_x(0,2)
end)
hotkey.bind({"cmd", "alt", "ctrl"}, "right", function()
move_win_x(1,2)
end)
hotkey.bind({"cmd", "alt", "ctrl"}, "up", function()
move_win_y(0,2)
end)
hotkey.bind({"cmd", "alt", "ctrl"}, "down", function()
move_win_y(1,2)
end)
-- max
hotkey.bind({"cmd", "alt", "ctrl"}, "m", function()
local win = window.focusedwindow()
local f = win:frame()
local s = win:screen():frame()
win:setframe(s)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment