Skip to content

Instantly share code, notes, and snippets.

@iwinux
Last active August 29, 2015 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwinux/05f8bc57bb8d50bbc7f8 to your computer and use it in GitHub Desktop.
Save iwinux/05f8bc57bb8d50bbc7f8 to your computer and use it in GitHub Desktop.
window centering
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