Skip to content

Instantly share code, notes, and snippets.

@jbfriedrich
Created April 18, 2021 11:27
Show Gist options
  • Save jbfriedrich/6021f6aef91275eb5db2a1fcf55d581f to your computer and use it in GitHub Desktop.
Save jbfriedrich/6021f6aef91275eb5db2a1fcf55d581f to your computer and use it in GitHub Desktop.
Hammerspoon configuration to replace the functionality of the now deprecated Mosaic app (used in tandem with Reactangle.app)
--------------------------------------------------------------------------------
-- Hammerspoon config to replace parts of Mosaic
--
-- References:
-- * https://www.hammerspoon.org/go/
-- * https://www.hammerspoon.org/docs/index.html
--------------------------------------------------------------------------------
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "n", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = 1280
f.h = 800
f.x = ((max.w - f.w) / 2) + max.x
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "p", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = 1920
f.h = 1080
f.x = ((max.w - f.w) / 2) + max.x
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "b", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = 1024
f.h = 600
f.x = ((max.w - f.w) / 2) + max.x
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "f", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = 1050
f.h = 800
f.x = ((max.w - f.w) / 2) + max.x
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "]", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = 570
f.h = 900
f.x = ((max.w - f.w) / 2) + max.x
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "[", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.w = 570
f.h = 478
f.x = ((max.w - f.w) / 2) + max.x
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "\\", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
local fullscreen = screen:fullFrame()
f.w = 663
f.h = (max.h * 0.85)
f.x = max.w - (f.w * 1.025)
f.y = ((max.h - f.h) / 2) + max.y
win:setFrame(f)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment