Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active March 27, 2022 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chmouel/362d244d3d7d3b3e2546fb7bb2b17469 to your computer and use it in GitHub Desktop.
Save chmouel/362d244d3d7d3b3e2546fb7bb2b17469 to your computer and use it in GitHub Desktop.
Focus back and forth between an application (kitty) to the previous window
global previousWin
on getFrontWin()
tell application "System Events"
set frontApp to first application process whose frontmost is true
set frontAppName to name of frontApp
return frontAppName
end tell
end getFrontWin
on switchBackForth()
if (getFrontWin() = "kitty") then
tell application previousWin
activate
end tell
else if isAppRunning("kitty") then
set previousWin to getFrontWin()
tell application "kitty"
activate
end tell
else
set previousWin to getFrontWin()
activate application "kitty"
end if
end switchBackForth
on isAppRunning(appName)
tell application "System Events" to (name of processes) contains appName
end isAppRunning
on alfred_script(q)
switchBackForth()
end alfred_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment