fix(hammerspoon): change to Apple Script for better compability

This commit is contained in:
Stefan Imhoff
2023-07-14 13:53:11 +02:00
parent 7381f16c5f
commit dc73a4b7a1

View File

@@ -124,15 +124,10 @@ function launchToggleApplication(applicationName)
if app:isHidden() then if app:isHidden() then
app:unhide() app:unhide()
else else
-- Some apps don't allow hiding, so Apple Script is needed HideApplicationWithAppleScript(app)
if app:hide() == false then
HideApplicationWithAppleScript(app)
else
app:hide()
end
end end
else else
app:activate() ShowApplicationWithAppleScript(app)
end end
else else
app:activate() app:activate()
@@ -154,6 +149,18 @@ function HideApplicationWithAppleScript(app)
hs.osascript.applescript(formattedScript) hs.osascript.applescript(formattedScript)
end end
-- Show application with AppleScript
function ShowApplicationWithAppleScript(app)
local appName = app:name()
local showScript = [[
tell application "Finder"
set visible of process "%s" to true
end tell
]]
local formattedScript = string.format(showScript, appName)
hs.osascript.applescript(formattedScript)
end
function Yabai(commands) function Yabai(commands)
for _, cmd in ipairs(commands) do for _, cmd in ipairs(commands) do
os.execute("/opt/homebrew/bin/yabai -m " .. cmd) os.execute("/opt/homebrew/bin/yabai -m " .. cmd)