Last active
August 29, 2015 14:13
-
-
Save iwinux/05f8bc57bb8d50bbc7f8 to your computer and use it in GitHub Desktop.
window centering
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 window = require "mjolnir.window" | |
local hotkey = require "mjolnir.hotkey" | |
local desiredWidth = 1024 | |
local desiredHeight = 768 | |
hotkey.bind({"cmd", "shift"}, "m", function() | |
local win = window.focusedwindow() | |
local screenBounds = win:screen():frame() | |
local destX = (screenBounds.w - desiredWidth) / 2 + screenBounds.x | |
local destY = (screenBounds.h - desiredHeight) / 2 + screenBounds.y | |
win:setframe({ x = destX, y = destY, w = desiredWidth, h = desiredHeight }) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment