Created
June 6, 2019 04:02
-
-
Save teki/2c4c32d96eb5a970681333753d822829 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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