Skip to content

Instantly share code, notes, and snippets.

@emjayoh
Created May 8, 2020 01:02
Show Gist options
  • Save emjayoh/ad01f6483256a98a5f6fb3bc7a6da14f to your computer and use it in GitHub Desktop.
Save emjayoh/ad01f6483256a98a5f6fb3bc7a6da14f to your computer and use it in GitHub Desktop.
Hammerspoon - kitty terminal + dropdown visor (Guake)
hs.hotkey.bind({}, "F15", function()
local app = hs.application.get("kitty")
if app then
if not app:mainWindow() then
app:selectMenuItem({"kitty", "New OS window"})
elseif app:isFrontmost() then
app:hide()
else
app:activate()
end
else
hs.application.launchOrFocus("kitty")
app = hs.application.get("kitty")
end
app:mainWindow():moveToUnit'[100,50,0,0]'
app:mainWindow().setShadows(false)
end)
@svenjacobs
Copy link

Line 6 doesn't work anymore with Kitty 0.26.4. It now should be

app:selectMenuItem({"Shell", "New OS Window"})

@svenjacobs
Copy link

Also I noticed that the positioning of the window doesn't work reliably on first start of Kitty. Here's my modified version of the script.

local app = hs.application.get("kitty")
local didHide = false

if app then
    if not app:mainWindow() then
        app:selectMenuItem({"Shell", "New OS Window"})
    elseif app:isFrontmost() then
        app:hide()
        didHide = true
    else
        app:activate()
    end
else
    hs.application.launchOrFocus("kitty")
    app = hs.application.get("kitty")
end

if not didHide then
  hs.timer.waitUntil(
    function() return app:isFrontmost() end,
    function() app:mainWindow():moveToUnit('[0,0,100,50]', 0) end
  )
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment