hs.loadSpoon("SpoonInstall")
spoon.SpoonInstall.use_syncinstall = true
spoon.SpoonInstall:andUse("WindowScreenLeftAndRight")
spoon.SpoonInstall:andUse("WindowHalfsAndThirds")
spoon.SpoonInstall:andUse("Commander")
spoon.SpoonInstall:andUse("ReloadConfiguration")

TERMINAL_NAME = "WezTerm"

spoon.WindowScreenLeftAndRight:bindHotkeys(spoon.WindowScreenLeftAndRight.defaultHotkeys)

spoon.WindowHalfsAndThirds:bindHotkeys(spoon.WindowHalfsAndThirds.defaultHotkeys)

spoon.ReloadConfiguration:start()

pcall(require, "initlocal")

hs.hotkey.bind({"cmd", "alt", "ctrl"}, "SPACE", function () 
    spoon.Commander.show()
end)

hs.hotkey.bind({"ctrl"}, "t", function () 
    local currentApp = hs.window.focusedWindow():application()
    if (currentApp:name() == TERMINAL_NAME) then
        hs.eventtap.keyStroke({"ctrl"}, "t", 1000, currentApp)
    else
        hs.application.launchOrFocus(TERMINAL_NAME)
    end
end)

hs.hotkey.bind({"cmd", "alt"}, ",", function ()
    hs.application.launchOrFocus("System Preferences")
end)

hs.hotkey.bind({"cmd", "shift"}, "l", function ()
    hs.application.launchOrFocus("Launchpad")
end)