mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-03 20:25:30 +00:00
fix(hammerspoon): change to Apple Script for better compability
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user