67 lines · 1.2 KB
local hotkey = require("hs.hotkey")

-- Disable animations
hs.window.animationDuration = 0

-- Window management
do
	local modifiers = { "alt", "ctrl", "cmd" }

	-- Left
	hotkey.bind(modifiers, "left", function()
		local win = hs.window.focusedWindow()
		local f = win:frame()
		local screen = win:screen()
		local max = screen:frame()

		f.x = max.x
		f.y = max.y
		f.w = max.w / 2
		f.h = max.h
		win:setFrame(f)
	end)

	-- Right
	hotkey.bind(modifiers, "right", function()
		local win = hs.window.focusedWindow()
		local f = win:frame()
		local screen = win:screen()
		local max = screen:frame()

		f.x = max.x + (max.w / 2)
		f.y = max.y
		f.w = max.w / 2
		f.h = max.h
		win:setFrame(f)
	end)

	-- Center
	hotkey.bind(modifiers, "C", function()
		local win = hs.window.focusedWindow()