Last active
March 27, 2022 07:01
-
-
Save chmouel/362d244d3d7d3b3e2546fb7bb2b17469 to your computer and use it in GitHub Desktop.
Focus back and forth between an application (kitty) to the previous window
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
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