Created
May 8, 2020 01:02
-
-
Save emjayoh/ad01f6483256a98a5f6fb3bc7a6da14f to your computer and use it in GitHub Desktop.
Hammerspoon - kitty terminal + dropdown visor (Guake)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Yes, it is expected to enable accessibility, or else hammerspoon does not have permissions to specific APIs.
As for setShadows
, it is stated that it is fragile.
This function uses a private, undocumented OS X API call, so it is not guaranteed to work in any future OS X release
Line 6 doesn't work anymore with Kitty 0.26.4
. It now should be
app:selectMenuItem({"Shell", "New OS Window"})
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
Hi,
"setShadows()" gives error
on MacOS Big Sur 11.2.3 & Hammerspoon 0.9.90 (6030).
Also, "Enable Accessibility" should be enabled from Hammerspoon > Preferences. (for once if not enabled, or installed recently) Otherwise script is not working as expected. 😉